ElasticSearch: No filter registered for [match]]

后端 未结 3 1232
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 01:48

I\'m trying to do this query to my ElasticSearch Server.

{
    \"query\" : {
        \"match\" : {
            \"name\" : \"network\"
        }
    },
    \"         


        
相关标签:
3条回答
  • 2020-12-16 02:21

    For anyone coming across this who migrated up major version(s) to elastic search 5, this filtered query is now depreciated and you should use a bool query instead. https://discuss.elastic.co/t/no-query-registered-for-filter/49602

    0 讨论(0)
  • 2020-12-16 02:22

    match is a query, not a filter.

    You probably want the term-filter in this case.

    0 讨论(0)
  • 2020-12-16 02:27

    Elasticsearch Advanced Filtering

    Here's a way you can use match inside of a bool:

    {
      "query": {
        "filtered": {
          "query": { //THIS IS THE MAIN SEARCH BLOCK FOR ALL RESULTS
            "match": { 
              "title": { 
                "query": "[MAIN_SEARCH_TERM]", 
                "minimum_should_match": "75%"
              }
            }
          },
          "filter": {
            "bool": {
              "must": [
                {
                  "range": { //THIS FILTERS BY DATES GRATER THAN [SOME_DATE]
                    "date": {
                      "gte":"[SOME DATE]"
                    }
                  }
                },
                {
                  "geo_distance": { //THIS FILTERS BY GEO POINTS WITHIN [DISTANCE] of [LATITUDE], [LONGITUDE]
                    "distance": "[DISTANCE](mi, km)",
                    "location": {
                      "lat":"[LATITUDE]",
                      "lon":"[LONGITUDE]"
                    }
                  }
                }
              ],
              "should": [
                {
                  "query": { //THIS FILTERS BY ANOTHER [MATCH_TERM] AND ADDS BOOST TO THAT TERM, YOU CAN USE MULTIPLE OF THESE WITH DIFFERENT [BOOST_INT]
                    "match": { 
                      "[PROPERTY]": {
                        "query": "[MATCH_TERM]",
                        "boost": [BOOST_INT]
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
    

    Reference Link: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/query-time-boosting.html

    Before using geo_point matching and date range filtering, make sure you understand _mapping: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping.html

    0 讨论(0)
提交回复
热议问题