How do I implement the following query using Java ApI? Thanks! curl -XGET http://localhost:9200/cs/csdl/_search?pretty=true -d ' { "query":{ "function_score": { "functions": [ { "boost_factor": "-10", "filter": { "terms" : {"abbrev" : ["computer"] } } } ], "query": { "filtered": { "query" : { "multi_match" : { "fields" : ["title"], "query" : ["computer"] } }, "filter": { "bool": { "must": { "range": { "pubdate": { "gte": "1890-09" , "lte":"2014-08" } } },
"must" : { "terms" : { "abbrev" : ["computer","annals","software"] } } } } } } } } }' On Tuesday, June 10, 2014 1:39:57 PM UTC-7, Jörg Prante wrote: > > Try this > > import org.elasticsearch.action.search.SearchRequest; > import > org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; > > import java.util.Arrays; > > import static org.elasticsearch.client.Requests.searchRequest; > import static org.elasticsearch.index.query.FilterBuilders.termsFilter; > import static org.elasticsearch.index.query.QueryBuilders.matchQuery; > import static > org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.factorFunction; > import static > org.elasticsearch.search.builder.SearchSourceBuilder.searchSource; > > public class FunctionScoreTest { > > public void testFunctionScore() { > SearchRequest searchRequest = searchRequest() > .source(searchSource().query(new > FunctionScoreQueryBuilder(matchQuery("party_id", "12")) > .add(termsFilter("course_cd", > Arrays.asList("writ100", "writ112", "writ113")), factorFunction(3.0f)))); > } > } > > Jörg > > > On Tue, Jun 10, 2014 at 11:16 AM, Jayanth Inakollu <ibsjaya...@gmail.com > <javascript:>> wrote: > >> I need to implement the below function_score query using Java APIs. I >> couldn't find any official documentation for function_score query in the >> Java API section of elasticsearch >> >> "function_score": { >> "functions": [ >> { >> "boost_factor": "3", >> "filter": { >> "terms" : {"course_cd" : ["writ100", "writ112", >> "writ113"] } >> } >> } >> ], >> "query": { >> "match" : { >> "party_id" : "12" >> } >> } >> } >> >> Please help! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "elasticsearch" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to elasticsearc...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elasticsearch/56d92aab-a4d7-4757-9441-f248c5296b3c%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elasticsearch/56d92aab-a4d7-4757-9441-f248c5296b3c%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/311c8492-8e78-4188-847c-44d7d115b464%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.