2016-04-14 73 views
0

如果有人可以提供幫助嗎? 1.全文搜索查詢,其中標題和描述都是頂級域ElasticSearch - 在嵌套字段上進行全文本搜索

GET /docidx/Document/_search 
{ 
    "query": { 
     "query_string": { 
      "query": "title:computer AND description:electronics" 
     } 
    } 
} 

This works fine. 

2. The full text search query where title is top level field but "abstract.content" i.e content is a nested field under abstract - does not return results. 

GET /docidx/Document/_search 
{ 
    "query": { 
     "query_string": { 
      "query": "title:computer AND abstract.content:memory" 
     } 
    } 
} 

Does Elastic Search has support for full text search for nested fields? 

回答

0

使用mustnested Query組合:

GET /docidx/Document/_search 
{ 
"query": { 
    "bool": { 
    "must": [ 
     { 
      "query_string": { 
       "default_field": "title", 
       "query": "computer" 
      } 
     }, 
     { 
      "nested": { 
       "path": "abstract", 
       "query": { 
       "query_string": { 
        "default_field": "abstract.content", 
        "query": "memory" 
       } 
       } 
      } 
      } 
     ] 
     } 
    } 
    } 
+0

但如何分析這句話「的稱號:計算機和抽象。內容:記憶」。或者可能有一些複雜的短語,例如: - 「((title:computer AND description:electronics OR(serialNum:123 AND misc:test))OR server」 – sanesearch

+0

你不能在同一個query_string中夾入嵌套和非嵌套字段。所有嵌套的字段在一個查詢中並且不嵌套在其他查詢中,並且根據需要在兩者之間應用「必須」或「應該」 – Richa

相關問題