I am trying to write a query with the following criteria:
- The query has a regular expression and the document must contain a hit
- The query has a list of words and at least one of the words must appear within N words of the regular expression. I want to use slop between the regular expression and the list of terms.
Here is what I have come up with so far. It finds hits on the regexp and the list of terms but not within N words of each other.
{
"from": 0,
"size": 100,
"explain": true,
"_source": {
"includes": [
"*"
],
"excludes": [
"FileText"
]
},
"query": {
"bool": {
"must": {
"regexp": {
"FileText": {
"value": "[0-9]{3}"
}
}
},
"should": {
"match": {
"FileText": {
"query": "list words find please",
"minimum_should_match": "1%"
}
}
}
}
}
}
I also tried
{
"from": 0,
"size": 100,
"explain": false,
"_source": {
"includes": [
"*"
],
"excludes": [
"FileText"
]
},
"query": {
"bool": {
"must": [
{
"regexp": {
"FileText": {
"value": "[0-9]{3}"
}
}
},
{
"match": {
"FileText": {
"query": "list words find please"
}
}
}
]
}
}
}
This finds documents with the regex and terms but they are not in proximity to each other.
Thanks in advance for any guidance you can provide.