Wildcards in exact phrase in query_string search

Hi,

Is it possible to include wildcards in a query_string query when looking
for a phrase?

When I search with the following query :

{
"query":{
"query_string":{
"default_operator" : "AND"
"analyze_wildcard": true,
"default_field":"value",
"query":""hotel california""
}
}

I get some hits which contain the phrase "hotel california" as expected.

However, if I search using

{
"query":{
"query_string":{
"default_operator" : "AND"
"analyze_wildcard": true,
"default_field":"value",
"query":""hotel c*""
}
}

I get no hits at all.

Does anyone know why this is the case? Is there a workaround?

Cheers,

Dara

On Wednesday, July 25, 2012 6:00:44 PM UTC+2, Dara wrote:

Hi,

Is it possible to include wildcards in a query_string query when looking
for a phrase?

When I search with the following query :

{
"query":{
"query_string":{
"default_operator" : "AND"
"analyze_wildcard": true,
"default_field":"value",
"query":""hotel california""
}
}

I get some hits which contain the phrase "hotel california" as expected.

However, if I search using

{
"query":{
"query_string":{
"default_operator" : "AND"
"analyze_wildcard": true,
"default_field":"value",
"query":""hotel c*""
}
}

you might wanna look at the text query part of the API. it has a
text_prefix_phrase query that might do what you are looking for.

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html

simon

I get no hits at all.

Does anyone know why this is the case? Is there a workaround?

Cheers,

Dara

Thanks for the reply, sorry for getting back so late but I've only started
looking at this again today.

On Wednesday, July 25, 2012 8:30:12 PM UTC+2, simonw wrote:

On Wednesday, July 25, 2012 6:00:44 PM UTC+2, Dara wrote:

Hi,

Is it possible to include wildcards in a query_string query when looking
for a phrase?

When I search with the following query :

{
"query":{
"query_string":{
"default_operator" : "AND"
"analyze_wildcard": true,
"default_field":"value",
"query":""hotel california""
}
}

I get some hits which contain the phrase "hotel california" as expected.

However, if I search using

{
"query":{
"query_string":{
"default_operator" : "AND"
"analyze_wildcard": true,
"default_field":"value",
"query":""hotel c*""
}
}

you might wanna look at the text query part of the API. it has a
text_prefix_phrase query that might do what you are looking for.

http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html

I've playing with text_prefix_phrase and it seems to be sort of what I'm
after, but the number of results returned is very dependent on the value of
max_expansions and the length of my prefix :

E.g
{
"query" : {
"text_phrase_prefix" : {
"value" : {
"query" : "Hotel Cali",
"max_expansions" : 0
}
}
}
}

will return some results but

{
"query" : {
"text_phrase_prefix" : {
"value" : {
"query" : "Hotel C",
"max_expansions" : 0
}
}
}
}

won't.

Nor does
{
"query" : {
"text_phrase_prefix" : {
"value" : {
"query" : "Hotel C",
"max_expansions" : 1
}
}
}
}

Whereas

{
"query" : {
"text_phrase_prefix" : {
"value" : {
"query" : "Hotel C",
"max_expansions" : 99
}
}
}
}

will return some results.

I don't really understand what max_expansions is doing, and what its value
actually means, can somebody explain in simple terms? What is being
expanded? The query? And if that is the case, how is it being expanded?

Thanks,

Dara

simon

I get no hits at all.

Does anyone know why this is the case? Is there a workaround?

Cheers,

Dara

--

Dara,

Realizing that this is an old post, but I am having this same issue.

Was there a suggested solution that got you through

Eric

Hi Eric,

I'm sorry but I didn't find a solution. If you do have any luck with this, please post back!

Cheers,

Dara