2016-08-18 12 views
0

問題があります。 私はたくさんの問い合わせをしようとしましたが、どのドキュメントも返されませんでした。弾性検索の範囲値検索、結果を返さない

マイデータ・フォーマットのようなものです:

{ 
    "_index": "orders", 
    "_type": "order", 
    "_id": "AVad66hjiOD-asNwVILB", 
    "_score": 1, 
    "_source": { 
     "document": { 
     "orderID": "1337", 
     "sku": "awesomeSku", 
     "customerID": "7331", 
     "productID": "20490859", 
     "variantID": "97920239", 
     "createTime": "2016-07-13T13:23:19Z", 
     "retailPrice": "10000", 
     "costPrice": "10000", 
     "new": 123 
     } 
    } 
    } 

マイクエリ:

{ 
"query": { 
"bool": { 
    "filter": [ 
    { "range": { "new": { "gte": "20" } } } 
    ] 
} 
    } 
} 

は、私は単にどこかに開始し、上記の値を持つ「新しい」属性を持つすべてのドキュメントを検索します20. フィードバックは素晴らしいです。

編集:ESで

データformart:

{ 
"orders": { 
"mappings": { 
    "order": { 
    "properties": { 
     "document": { 
     "properties": { 
      "costPrice": { 
      "type": "string" 
      }, 
      "createTime": { 
      "type": "string" 
      }, 
      "customerID": { 
      "type": "string" 
      }, 
      "new": { 
      "type": "long" 
      }, 
      "orderID": { 
      "type": "string" 
      }, 
      "productID": { 
      "type": "string" 
      }, 
      "retailPrice": { 
      "type": "string" 
      }, 
      "sku": { 
      "type": "string" 
      }, 
      "variantID": { 
      "type": "string" 
      } 
     } 
     } 
    } 
    } 
    } 
} 
} 
+0

'curl -XGET localhost:orders/_mapping/order'から取得したマッピングで質問を更新できますか?あなたの 'new'フィールドは、数字と文字列" 20 ">" 123 "の代わりに文字列としてマップされるかもしれません。なぜ結果が得られないのですか? – Val

+0

これは: "new":{"type": "long"} – Kiksen

答えて

1

すべてのフィールドがトップレベルdocumentセクションにネストされているので、あなたがdocument.newフィールドに、このようなクエリを行う必要があります。

{ 
    "query": { 
    "bool": { 
     "filter": [ 
     { 
      "range": { 
      "document.new": { 
       "gte": 20 
      } 
      } 
     } 
     ] 
    } 
    } 
} 
+0

ありがとうございます。私は今眠るべきです。 私の愚かなので:) もう一度感謝します。 – Kiksen

+0

心配はありません。時には目の第二のペアが役立ちます。うれしいことに私たちはそれを理解しました;-) – Val

関連する問題