Note that there are some explanatory texts on larger screens.

plurals
  1. POelasticsearch : Nested Document Mapping not working
    primarykey
    data
    text
    <p>I have following json structure in elastic search which stored @ <code>http://localhost:9200/mongoindex/documents/</code> :</p> <pre><code>{ "text" : "OTesting1" "otag" : "otag1" "pages" : [{ "text" : "1" "name" : "itag1" }, { "text" : "2" "name" : "itag2" } ] } </code></pre> <p>I have created nested mapping as following to enable nested search and nested filter on it :</p> <pre><code>http://localhost:9200/mongoindex/documents/_mapping [PUT] { "documents": { "properties": { "pages": { "type": "nested" } } } } </code></pre> <p>Now executed following java code :</p> <pre><code>Settings settings = ImmutableSettings.settingsBuilder() .put("cluster.name", "xyz").build(); Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("localhost", 9300)); SearchResponse response = client.prepareSearch("mongoindex") .setTypes("documents") .setQuery(QueryBuilders.nestedQuery("documents", QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("pages.text", "1"))).scoreMode("avg")) .execute() .actionGet(); </code></pre> <p>but its giving me following exception :</p> <pre><code>&gt; Exception in thread "main" &gt; org.elasticsearch.action.search.SearchPhaseExecutionException: Failed &gt; to execute phase [query], total failure; shardFailures &gt; {[kSKaBxjGTMSS352kukrYVw][mongoindex][0]: &gt; SearchParseException[[mongoindex][0]: from[-1],size[-1]: Parse Failure &gt; [Failed to parse source &gt; [{"query":{"nested":{"query":{"bool":{"must":{"match":{"pages.text":{"query":"1","type":"boolean"}}}}},"path":"documents","score_mode":"avg"}}}]]]; &gt; nested: QueryParsingException[[mongoindex] [nested] nested object &gt; under path [documents] is not of nested type]; &gt; }{[kSKaBxjGTMSS352kukrYVw][mongoindex][4]: &gt; SearchParseException[[mongoindex][4]: from[-1],size[-1]: Parse Failure &gt; [Failed to parse source &gt; [{"query":{"nested":{"query":{"bool":{"must":{"match":{"pages.text":{"query":"1","type":"boolean"}}}}},"path":"documents","score_mode":"avg"}}}]]]; &gt; nested: QueryParsingException[[mongoindex] [nested] nested object &gt; under path [documents] is not of nested type]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload