0

Everyone. This is a simple test code with the elasitcsearch document 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,"balance":100000,"name":"Thomas.St.Wang"} }, { "_index" : "customer", "_type" : "external", "_id" : "2", "_score" : 1.0, "_source":{"age":19,"balance":10000,"name":"T.S.W"} } ] } }


The following request is not the result i expect. Why.

 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, "hits" : [ ] } }

What's wrong with my query? Thanks.

1 Answer 1

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

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

This is the answer. Because the balance filed is a string. I need delete the index,and restart index it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.