2012-12-20 27 views
4

我們在我們的映射中使用了minimal_english詞幹程序過濾器。這是爲了確保只有單數和複數是可搜索的而不是相似的單詞。例如。 TestTests應該上輸入搜索項 - Test - 但TesterTestersTesting不應該。在嘗試使用下面的RESTful API進行搜索,multi_field屬性類型是可搜索的,但nested屬性類型不:如下所示Elasticsearch:單數和複數結果

curl -X GET "http://10.113.124.136:9400/libtester/_search?pretty=true" -d '{ 
    "query": { 
    "query_string": { 
     "query": " DescriptionDescription ", 
     "fields": [ 
     "abc" 
     ] 
    } 
    } 
}' 

映射:

{ 
    "properties": { 
    "abc": { 
     "type": "multi_field", 
     "fields": { 
     "c_asset_id": { 
      "type": "string", 
      "index": "analyzed", 
      "include_in_all": true, 
      "analyzer": "basic_english" 
     }, 
     "untouched": { 
      "type": "string", 
      "index": "analyzed", 
      "include_in_all": false, 
      "analyzer": "string_lowercase" 
     } 
     } 
    }, 
    "xyz": { 
     "type": "nested", 
     "properties": { 
     "c_viewpoint": { 
      "type": "multi_field", 
      "fields": { 
      "c_viewpoint": { 
       "type": "string", 
       "index": "analyzed", 
       "include_in_all": true, 
       "analyzer": "basic_english" 
      }, 
      "untouched": { 
       "type": "string", 
       "index": "analyzed", 
       "include_in_all": false, 
       "analyzer": "string_lowercase" 
      } 
      } 
     } 
     } 
    }, 
    ... 
    } 
} 

這是與映射做嵌套類型 - xyz,它們不能從多字段類型相同的API中搜索到?

回答

1

您可以搜索嵌套屬性,它只需要稍微不同的語法。您必須指定路徑,然後明確使用您正在搜索的每個屬性的路徑。

本教程有一個good overview of how nested documents work

+0

謝謝扎克,我已經能夠正確地搜索單數/複數的條款。但是,我注意到某些術語失敗,例如「鞋子」,「鼠標」和「葉子」。你能提出一些建議嗎? –

+0

可能與分析術語有關的問題,無論是搜索還是索引。這些術語中的兩個具有非典型的複數形式(例如「老鼠」,「葉子」)。我的第一個猜測是,如何阻止某些事情是錯誤的,但是如果沒有看到完整的分析器就很難知道。 – Zach