Query String and match term equivalent

Hello, I'm trying to modify a previous query by query string that I made;

'query': {
'query_string': {
'fields': self._es_text_fields,
'query': content,
'default_operator': 'or'
}
}

where content is a string containing words separated by a space and self._es_text_fiels is a list of fields name.

Now I need to add an equivalent to:

'query': {
'match': {
'term': {'id': 0000000}
}
}

I cannot find a working combination of the two. Is it even possible?

I'm not sure if I understand your question correctly, but here are two things that might help.

This is how a term query should look like:

POST _search
{
  "query": {
    "term" : { "user" : "Kimchy" } 
  }
}

And this is how you would go about combining the two using a bool query:

POST _search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "user": "Kimchy"
          }
        },
        {
          "query_string": {
            "fields": "self.estext_fields",
            "query": "content",
            "default_operator": "or"
          }
        }
      ]
    }
  }
}

Thanks, it's working like a charm now :slight_smile:

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