1

I'm writing ElasticSearch (v 1.7) query to find all urls that do not start with http. But my mapping results with an empty result (while I definitely have urls not starting with http). Could you help me to fix it?

"query": {
  "regexp":{
    "url": {
      "value": "@&~(http.+)",
      "flags" : "ANYSTRING"
    }
  }
} 
1
  • Use "flags" : "ALL" or remove "flags" : "ANYSTRING" without adding anything Commented Aug 9, 2019 at 13:40

1 Answer 1

1

Your query should work once you remove the flags:

"query": {
  "regexp":{
    "url": {
      "value": "@&~(http.+)",
    }
  }
} 

Or, if you use ALL (default) as flags value:

"query": {
  "regexp":{
    "url": {
      "value": "@&~(http.+)",
      "flags" : "ALL"
    }
  }
} 

ANYSTRING only enables the @ operator, while ~ is enabled with the COMPLEMENT flag, and & operator is enabled with the INTERSECTION flag. Basically, it is safer to go with the default value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.