Filter Query Issue

I am trying to achieve "AND" in filter .

Example: All those documents which has "PL" AND "rall" in there TAGS field.

Please let me know where I am wrong ?

My Query:

    {
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "should": [
            {
              "query_string": {
                "fields": [
                  "TITLE.title^5.5",
                  "TITLE.ngrams_front^2"
                ],
                "analyzer": "titles_default_analyzer",
                "query": "visa"
              }
            },
            {
              "fuzzy": {
                "TITLE.title": {
                  "value": "visa",
                  "boost": 2,
                  "max_expansions": 20,
                  "prefix_length": 0
                }
              }
            },
            {
              "query_string": {
                "fields": [
                  "SEARCHABLE.title^1.5",
                  "SEARCHABLE.ngrams_front^1"
                ],
                "analyzer": "titles_default_analyzer",
                "query": "visa"
              }
            },
            {
              "fuzzy": {
                "SEARCHABLE.title": {
                  "value": "visa",
                  "boost": 1,
                  "max_expansions": 20,
                  "prefix_length": 0
                }
              }
            },
            {
              "match_phrase_prefix": {
                "TITLE.title": {
                  "query": "visa",
                  "boost": 100
                }
              }
            }
          ],
          "filter": {
            "bool": {
              "must": [
                {
                  "terms": {
                    "TAGS": [
                      "PL"
                    ]
                  }
                },
                {
                  "terms": {
                    "TAGS": [
                      "rall"
                    ]
                  }
                }
              ]
            }
          }
        }
      },
      "field_value_factor": {
        "field": "BST_SCR_HGH",
        "modifier": "log"
      }
    }
  }
}

Hey,

you are running this filter inside of a function_score query, which basically means, that you want to apply the function only to such documents. If you want to filter out those documents, you have to put it outside of the function score query.

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.