Hacksign
(Hacksign)
January 4, 2016, 7:00am
1
If there is an data like below :
this is a test line contain notepad.exe.
this is not the line I want which contain notepad.exe for test
and hypothesis, I dont know all words in above sentence, what I know is below :
the sentence contains keyword 'test'
the sentence contains keyword 'notepad.exe'
keyword is in strict order: 'exe' after 'notepad', 'notepad' after 'test'
all keywords may not consecutively
Because reason 4, I can not use match_phrase query,so is there any way I can pick out first line with DSL query ?
Ivan
(Ivan Brusic)
January 4, 2016, 9:02pm
2
Look into span queries. They are not very performant, but offer loads more
flexibility than standard phrase queries.
https://www.elastic.co/guide/en/elasticsearch/reference/master/span-queries.html
msimos
(Mike Simos)
January 4, 2016, 10:08pm
3
Hi,
You can also do this:
{
"query": {
"query_string": {
"query": "\"test notepad.exe\"~2",
"default_operator": "AND"
}
}
}
https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-query-string-query.html#_proximity_searches