0

每个人。这是一个带有elasitcsearch 文档 url的简单测试代码

curl -XPOST 'localhost:9200/customer/external/_search?pretty'

{ "took" : 3, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 2, "max_score " : 1.0, "hits" : [ { "_index" : "customer", "_type" : "external", "_id" : "1", "_score" : 1.0, "_source":{"age":20 “余额”:100000,“名称”:“Thomas.St.Wang”} },{“_index”:“客户”,“_type”:“外部”,“_id”:“2”,“_score" : 1.0, "_source":{"age":19,"balance":10000,"name":"TSW"} } ] } }


以下请求不是我期望的结果。为什么。

 curl -XPOST 'localhost:9200/customer/external/_search?pretty' -d 



{  
   "query":{  
      "filtered":{  
         "query":{  
            "match_all":{  

            }
         },
         "filter":{  
            "range":{  
               "balance":{  
                  "gte":9999,
                  "lte":100001
               }
            }
         }
      }
   }
}

{ "took" : 2, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 0, "max_score " : null, "命中" : [ ] } }

我的查询有什么问题?谢谢。

4

1 回答 1

0
 curl -XGET 'localhost:9200/customer/_mapping/external/field/balance'

{"customer":{"mappings":{"external":{"balance":{"full_name":"balance","mapping":{"balance":{"type":"string"}}}} }}}

这就是答案。因为余额归档是一个字符串。我需要删除索引,然后重新启动索引。

于 2017-03-22T02:43:23.050 回答