Meine verschachtelten_Filter funktionieren nicht, auch nicht meine verschachtelte Abfrage. I'have eine Abbildung wie folgt erstellen:Abfrage geschachtelte Dokumente auf ElasticSearch
curl -XPUT 'localhost:9200/i_part' -d '
{
"mappings": {
"part2": {
"properties": {
"p_name": {
"type": "string", "index": "not_analyzed"
},
"lineorder": {
"type": "nested",
"properties": {
"lo_quantity": {"type":"integer"},
"lo_discount": {"type":"integer"},
"lo_shippriority": {"type": "string", "index": "not_analyzed"},
"lo_shipmode": {"type": "string", "index": "not_analyzed"},
"customer"{
"properties":{
"c_name": {"type": "string", "index": "not_analyzed"}
}
}
}
}
}
}
}
}
Aber wenn ich fragen sie den Weg unter alles Dokument zurückgibt.
curl -XPOST 'localhost:9200/i_part/part2/_search?pretty' -d '
{
"query": {
"filtered": {
"filter": {
"nested" : {
"path" : "lineorder",
"filter": {
"and": [
{
"match" : {
"lineorder.lo_shipmode":"RAIL|"
}
},
{
"match" : {
"lineorder.lo_orderpriority":"1-URGENT"
}
}
]
}
}
}
}
},
"query": {
"bool": {
"must": [
{ "match": { "p_partkey": 1 }},
{
"nested": {
"path": "lineorder",
"query": {
"bool": {
"must": [
{"match": {"lineorder.lo_shipmode":"RAIL|"}},
{"match" : {"lineorder.lo_orderpriority":"1-URGENT"}}
]
}}}}
]
}}
}'
oder auf diese Weise
curl -XGET 'localhost:9200/i_part/part2/_search?pretty' -d '
{
"query": {
"nested": {
"path": "lineorder",
"filter": {
"range": {
"lineorder.lo_discount": {
"gte": 2,
"lt": 4
}
}
}
}
},
"sort": {
"lineorder.lo_discount": {
"order": "asc",
"nested_filter": {
"range": {
"lineorder.lo_discount": {
"gte": 2,
"lt": 4
}
}
}
}
}
}'
Was mache ich falsch? Ich möchte verschachtelte Felder nicht übergeordnet/untergeordnet abfragen, da meine Daten zu groß sind, um das untergeordnete Element mit dem übergeordneten Element zu verknüpfen.
Meine Daten ist so etwas wie dieses:
{
"p_name": "lace spring",
"lineorder": [{
"customer": [{
"c_name": "Customer#000014704",
}],
"lo_quantity": 49,
"lo_orderpriority": "1-URGENT",
"lo_discount": 3,
"lo_shipmode": "RAIL|",
"lo_tax": 0
}, {
"customer": [{
"c_name": "Customer#000026548",
}],
"lo_quantity": 15,
"lo_orderpriority": "3-MEDIUM",
"lo_discount": 10,
"lo_shipmode": "SHIP|",
"lo_tax": 0
}]}
Können Sie ein Beispieldokument hinzufügen, von dem Sie erwarten, dass diese Abfrage zurückgegeben wird? – mbudnik
In Ihrer ersten Abfrage verwenden Sie 'match' in nicht analysierten Feldern. Es wird nicht funktionieren. – DrTyrsa
@DrTyrsa Ich habe "Begriff" auch versucht, aber das gleiche Problem. – Raphael