========嘗試在列表上查詢,但未能正常工作=============
輸入記錄:在ElasticSearch上查詢列表時沒有獲得預期的輸出
{ "somerecord": [ { "fieldValue": "1", "sampleKey": [ "1", "2" ] }, { "fieldValue": "2", "sampleKey": [ "3", "4" ] } ] }
輸出預期或需要「fieldValue方法」:」 1」 搜索:
{ "fieldValue": "1", "sampleKey": [ "1", "2" ] }
個步驟:
創建一個映射
使用不同的查詢類型
參考把記錄
查詢:
http://www.spacevatican.org/2012/6/3/fun-with-elasticsearch-s-children-and-nested-documents/ https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-mapping.html https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html https://gist.github.com/nicolashery/6317643 http://elasticsearch-cheatsheet.jolicode.com/ http://obtao.com/blog/2014/04/elasticsearch-advanced-search-and-nested-objects/ http://joelabrahamsson.com/elasticsearch-nested-mapping-and-filter/
請讓我知道如何實現我的意圖。
========一些命令運行的=========
1.
curl -XPOST https://someClusterURL/tax2 -d '{ "mappings": { "ids": { "properties": { "somerecord": { "type": "nested", "properties": { "fieldValue": { "type": "string" } } } } } } }'
-
curl -XPUT https://someClusterURL/tax2/ids/1 -d '{ "somerecord": [ { "fieldValue": "1", "sampleKey": [ "1", "2" ] }, { "fieldValue": "2", "sampleKey": [ "3", "4" ] } ] }'
3.
curl -XGET https://someClusterURL/tax2/ids/_search -d '{ "query": { "nested": { "path": "somerecord", "query": { "bool": { "must": [ { "match": { "fieldValue": "1" }} ] } } } } }'
結果:
{ "somerecord": [ { "fieldValue": "1", "sampleKey": [ "1", "2" ] }, { "fieldValue": "2", "sampleKey": [ "3", "4" ] } ] }
嘗試了,但仍然沒有工作。
謝謝Richa。我嘗試過,得到了我在inner_hits中尋找的子元素。但是我的問題還沒有在這裏結束,我不想完整記錄。我檢查了inner_hits和其他選項,看不到設置爲禁用完整的記錄作出迴應。讓我知道它是否可能。 –
@VenkataraoN它是否適合你。 – Richa
謝謝Richa!它現在爲我工作。 –