Skip to content

Instantly share code, notes, and snippets.

@UpOutServers
Created October 29, 2012 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UpOutServers/3976983 to your computer and use it in GitHub Desktop.
Save UpOutServers/3976983 to your computer and use it in GitHub Desktop.
ScriptFilterBuilder dateFilter = scriptFilter(TimeframeFilterScriptFactory.NAME)
.lang("native")
.addParam("timeframe_type",timeframe_type);
ConstantScoreQueryBuilder constantChild = constantScoreQuery(dateFilter);
HasChildFilterBuilder hasChild = hasChildFilter(timeframe_type, constantChild);
ConstantScoreQueryBuilder constantDate = constantScoreQuery(hasChild);
CustomScoreQueryBuilder customScore = customScoreQuery(constantDate)
.lang("native")
.script(TimeframeSortScriptFactory.NAME)
.param("event_type",event_type);
SearchResponse response = client.prepareSearch(index)
.setTypes(event_type)
.setSearchType(DFS_QUERY_THEN_FETCH)
.setQuery(customScore)
.execute()
.actionGet();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment