Use regexp and terms together in query

Hi,

I am trying to use both a regexp and a terms query in the body of my query, and can't figure out how to make it work.

Goal:

             query: {
                regexp: {
                    'canonicalUrl.keyword': {
                        value: '.*targetString.*'
                    },
                },
                terms: {
                    'metros.keyword': ['atlanta-ga']
                }
            }

It works with one or the other, but not together. I get a parsing_exception I have tried wrapping in a bool and filter, which also hasn't worked. Anyone have any suggestions, or know whether or not this is possible?

I have tried it on my own data and the following query gives me result, however if I use 'terms' I am getting a parsing error.

{
  "size": 10,
  "query": {
    "bool": {
      "must": [
        {
          "regexp": {
            "error": "auth*"
          }
        },
        {
          "term": {
            "protocol": "pop3"
          }
        }
      ]
    }
  }
}

@pjanzen Hey, thanks for the response. Is your protocol value an array? For my case, I am checking to see if a particular string lives in the array, and the only way I've found that to work is to use terms. If you know another way that works, I'm all ears.

I have tried it where I have a list and this works too. (tags is a list)

{
  "size": 10,
  "query": {
    "bool": {
      "must": [
        {
          "regexp": {
            "mailUserStatus": "active*"
          }
        },
        {
          "term": {
            "tags": "mcldapm"
          }
        }
      ]
    }
  }
}

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