2017-10-16 207 views
0

我有一個字段,它是一個句子(字符串)數組。如果單詞在句子中,我想在數組內搜索。Elasticsearch查詢:在句子數組中匹配單詞

"fields": { 
      "title": [ 
       "The book of the world" 
      ] 
     } 

的簡單查詢 「書」 不返回預期的結果:

GET catalog/_search 
    { 
    "fields" : "title", 
    "query":{ 
     "match" : { 
      "title":"book" 
     } 
    } 
} 

你有一個想法?

+0

能告訴你的映射? GET目錄/ _映射 – Miek

+0

映射是:''tokenizer「:」standard「' – OussamaM

回答

1

在將數據添加到索引之前,您必須先配置分析器。

分析儀是將句子「拆分」爲標記(此處爲「」「世界」的「書」「或」移除停用詞「書」「世界」)的事物。

請務必閱讀正文https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html

文檔還關注如何Elasticsearch涉及陣列:https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html

+0

默認的分析器被一個不分割內容的分量重載 – OussamaM

1

在這種情況下,字段名是fields.title不是所有權。

嘗試:

GET catalog/_search 
{ 
    "fields" : "fields.title", 
    "query":{ 
     "match" : { 
      "fields.title":"book" 
     } 
    } 
} 
相關問題