java - ElasticSearch | Filter Query -


i using elasticsearch-1.7.1 , java dependency

<groupid>org.elasticsearch</groupid> <artifactid>elasticsearch</artifactid> <version>1.7.1</version> 

problem : using in clause in es when query es filtered query giving me null response.

contentquery = boolquery().must(querybuilders.matchquery(property_book_id, bookid).operator(operator.and))              .must(querybuilders.matchquery("contenttype", "enrichments").operator(operator.and))              .must(contentquery);     filteredquerybuilder builder =               querybuilders.filteredquery(contentquery, filterbuilders.termfilter("spineid","chapter04.html"));  searchresponse = searchclientservice.getclient()                 .preparesearch(index_name).settypes(index_type)                 .setquery(builder)                 .execute().actionget(); 

without filter, working fine. can please suggest how apply filter query or let me know if going anywhere wrong while making requests.

query details :

{   "filtered" : {     "query" : {       "bool" : {         "must" : [ {           "match" : {             "bookid" : {               "query" : "d563739c-8b46-449b-b695-d662cb32087d",               "type" : "boolean",               "operator" : "and"             }           }         }, {           "match" : {             "contenttype" : {               "query" : "enrichments",               "type" : "boolean",               "operator" : "and"             }           }         }, {           "bool" : {             "must" : {               "match" : {                 "content" : {                   "query" : "resources*",                   "type" : "phrase_prefix"                 }               }             }           }         } ]       }     },     "filter" : {       "term" : {         "spineid" : "chapter04.html"       }     }   } } 

i've tried other filter queries on index, none of them working.below query must return result returning empty result.

{   "filtered" : {     "query" : {       "match_all" : { }     },     "filter" : {       "bool" : {         "must" : {           "term" : {             "spineid" : "chapter03.html"           }         }       }     }   } } 

mapping :

 private xcontentbuilder buildmapping() throws exception {         return jsonbuilder().prettyprint()                 .startobject()                     .startobject(indextype)                         .startobject("properties")                             .startobject(property_spine_id).field("type", "string").field("index", "not_analyzed").endobject()                         .endobject()                     .endobject()                 .endobject();     } xcontentbuilder source = jsonbuilder().startobject();         source.field(property_book_id, bookid)         .field(property_widget_id, widgetid)         .field(property_content, widgetdescription)         .field(property_content_type, contenttype.getvalue())         .field(property_meta_data, widgetjsonstring)         .field(property_spine_id, spineid)         .endobject(); 

any appreciated.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -