Regexp query for phrase

I need to search for two signature pattern with 'and' operator between two phrase. How to write the query for that. In these two phrase I as shown below the * means any number or value between 0-9 can be taken into consideration. How to write advance query for such type of pattern?
2 signature pattern- (GBUS error * timeout error) and​ (Asic * is not a valid chip)​

Easy way is use boolean query. You can use AND operation by must or filter clause.

Thanks for that. Will try boolean query but how to include the * condition as well which can take any value between 0-9?

There are regex query for regular expressions. If you are asking about the regular expression pattern, it seems you need to learn a little about regular expressions

GET 2021-0705-0486/_search
{
"query": {
"bool":{
"should":[
{"regexp": {"message.keyword": {
"value": ".GBUS error [0-9] timeout error.",
"flags": "ALL",
"case_insensitive": true,
"max_determinized_states": 10000,
"rewrite": "constant_score"}}
},
{"regexp": {"message.keyword": {
"value": ".Asic [0-9] is not a valid chip.",
"flags": "ALL",
"case_insensitive": true,
"max_determinized_states": 10000,
"rewrite": "constant_score"}}
}
]
}
}
}
This worked fine. Is this correct way to use regexp query for phrase with space along with bool query?

1 Like

That looks ok and even better if it's working well.
What is the intention of "." on the start/end of pattern? To guarantee that pattern occurs truely inside the keyword?

From next time, please preformat your json with </> button. Thanks.

Sorry its typo. I used .* in start and end to search pattern inside the keyword.
Thanks for help.

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