Lucene Query String Elasticsearch “less than or equal to”[URI Search]

前端 未结 2 1815
悲哀的现实
悲哀的现实 2021-01-31 02:41

On so many websites they teach how to query data from Elasticsearch using range query. I would like to query data that is less than or equal to a certain number from Elasticsear

2条回答
  •  花落未央
    2021-01-31 03:40

    I think you wanna query the documents with less than equal to 100.

     curl -XPOST "http://hostname:9200/index/try/_search" -d'
    {
     "query": {
        "range": {
          "FieldName": {
             "lte" : 100
          }
        }
      }
    }'
    

    PHP API client

    array(
    'query' => array(
        'range' => array(
            'FieldName' => array(
                array("lte" => 100)
            )
        )
      )
    );
    

    for more queries.. refer

    The query format thet you asked for..!

    curl -XPOST "http://hostname:9200/index/type/_search?q=FieldName:[* to 100]"
    

    HOpe it helps..!

提交回复
热议问题