Phrase query question


(Sagar Mehta) #1

Suppose I have a query "a system and method for retrieving". A phrase
query will return a hit only if a document contains all the terms in
the phrase. But what if I have a document which has the term:

"a system for retrieving"

but no mention of the keyword "method" anywhere in the document. Is
there any way to do a phrase query while allowing "deletion" of
certain terms so that i'd be able to match the above? I can think of
taking the long query and running smaller sub-phrase queries on it in
sequence, but I was wondering if there was a way to get this behavior
out of the box.


(David Pilato) #2

By default, a QueryString query is a OR query. So, I think your assertion : "A phrase query will return a hit only if a document contains all the terms in the phrase." is false.

If you query for "a system for retrieving", it will return your document.

HTH
David

Le 16 juil. 2012 à 03:24, Sagar Mehta svmknicks33@gmail.com a écrit :

Suppose I have a query "a system and method for retrieving". A phrase
query will return a hit only if a document contains all the terms in
the phrase. But what if I have a document which has the term:

"a system for retrieving"

but no mention of the keyword "method" anywhere in the document. Is
there any way to do a phrase query while allowing "deletion" of
certain terms so that i'd be able to match the above? I can think of
taking the long query and running smaller sub-phrase queries on it in
sequence, but I was wondering if there was a way to get this behavior
out of the box.


(Sagar Mehta) #3

Ok I see, I was using a Text query below instead of of a QueryString
query which is why I was getting only full matches. Thanks!

{
"fields" : ["title", "full"],
"query" : {
"text":{
"full": {
"query" : "System and method for information",
"type" : "phrase",
"slop": 100
}
}
},
"highlight" : {
"fields" : {
"order" : "score",
"full" : {"fragment_size" : 200, "number_of_fragments" : 3},
"title" : {"fragment_size" : 200, "number_of_fragments" : 3}
}
}
}

On Jul 15, 10:48 pm, David Pilato da...@pilato.fr wrote:

By default, a QueryString query is a OR query. So, I think your assertion : "A phrase query will return a hit only if a document contains all the terms in the phrase." is false.

If you query for "a system for retrieving", it will return your document.

HTH
David

Le 16 juil. 2012 à 03:24,SagarMehta svmknick...@gmail.com a écrit :

Suppose I have a query "a system and method for retrieving". A phrase
query will return a hit only if a document contains all the terms in
the phrase. But what if I have a document which has the term:

"a system for retrieving"

but no mention of the keyword "method" anywhere in the document. Is
there any way to do a phrase query while allowing "deletion" of
certain terms so that i'd be able to match the above? I can think of
taking the long query and running smaller sub-phrase queries on it in
sequence, but I was wondering if there was a way to get this behavior
out of the box.


(system) #4