2016-03-22 11 views
1

ネストされたクエリでも、自分のnested_filterは機能しません。 I'haveは、このようなマッピングを作成します: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"} 
         } 
       } 
      } 
} 
} 
} 
} 
} 

をしかし、私はそれを照会すると、その下の方法は、すべての文書を返します。

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"}} 
       ] 
     }}}} 
     ] 
}} 
}' 

またはこのよう私が間違ってやっている何

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 
      } 
     } 
     } 
    } 
    } 
}' 

?私のデータが大きすぎて親を子にリンクすることができないため、親/子ではないネストされたフィールドを照会したいと思います。あなたがlineorderをフィルタリングする場合は自分自身だあなたはinner hitsを使用する必要があります

{ 
    "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 
      }]} 
+1

このクエリで返されるサンプルドキュメントを追加できますか? – mbudnik

+1

最初のクエリでは、解析されていないフィールドで 'match'を使用しています。それは動作しません。 – DrTyrsa

+0

@DrTyrsa私も "用語"を試しましたが、同じ問題です。 – Raphael

答えて

1

私のデータは、このようなものです。

関連する問題