Reputation: 1370
I want to search for a specific string in a message, such that the string can have following values:
I'm using the following query to try to find these messages:
GET /my_index/_search
{
"query": {
"regexp":{
"message": "program.*process.*"
}
}
}
The above search is not giving any results at all. Though if I use
GET /my_index/_search
{
"query": {
"regexp":{
"message": "program.*"
}
}
}
it gives all the expected matches (though many more than what I want).
What am I doing wrong with the regex expression?
Upvotes: 1
Views: 215
Reputation: 217274
You could also use a match_phrase
query with a slop of 1. That's much more performant than using regexp queries:
POST test/_search
{
"query": {
"match_phrase": {
"text": {
"query": "program process",
"slop": 1
}
}
}
}
Upvotes: 1