Newbie Q

Hi,

Please could someone explain me what is wrong with this:

curl -XGET http://server:9200/medios/news/_search -d '{ "query" :
{ "term" : { "fuente" : "Avui" } } }'

while in the same time, this works great:

curl -XGET http://server:9200/medios/news/_search?q=fuente:Avui

I am quite sure that is should be something obvious but ... can't
figure it out :frowning:

Thank you!

In your get query example you used the "q=" syntax which causes a query
string search. In your json example you used a term query. Check the search
docs for query_string search to see the proper syntax
On Jan 12, 2011 11:11 AM, "Svet" svetef@gmail.com wrote:

On Wed, Jan 12, 2011 at 2:11 PM, Svet svetef@gmail.com wrote:

Hi,

Please could someone explain me what is wrong with this:

curl -XGET http://server:9200/medios/news/_search -d '{ "query" :
{ "term" : { "fuente" : "Avui" } } }'

while in the same time, this works great:

curl -XGET http://server:9200/medios/news/_search?q=fuente:Avui

I am quite sure that is should be something obvious but ... can't
figure it out :frowning:

I think the parameter q=fuente:Avui is equivalent to

{ "query":
{ "query_string":
{ "query": "fuente:Avui"
}
}
}

The "query_string" is parsed (and analyzed) into something very close to
your attempt:

{ "query": { "term" : { "fuente": "avui" } } }

My conjecture is that when "fuente:Avui" is parsed, the term "Avui" is
normalized to lowercase as "avui" โ€“ this should be the same which happens
when you index your documents (because the default query analyzer matches
the default index analyzer). So the "query_string" works ok, but not your
"term" query because that one does not analyze "Avui" and then you have no
match for this term with an uppercase letter "A".

So I suggest you try "avui" in lowercase at the "term" query. And probably
someone else in the list may confirm if I got that right.

My conjecture is that when "fuente:Avui" is parsed, the term "Avui" is
normalized to lowercase as "avui" รขย€ย“ this should be the same which
happens when you index your documents (because the default query
analyzer matches the default index analyzer). So the "query_string"
works ok, but not your "term" query because that one does not analyze
"Avui" and then you have no match for this term with an uppercase
letter "A".

So I suggest you try "avui" in lowercase at the "term" query. And
probably someone else in the list may confirm if I got that right.

exactly right

clint

Indeed, this was the problem. Thank you @Rich, @Adriano, @Clinton!

On 12 ene, 17:39, Adriano Ferreira a.r.ferre...@gmail.com wrote:

On Wed, Jan 12, 2011 at 2:11 PM, Svet sve...@gmail.com wrote:

Hi,

Please could someone explain me what is wrong with this:

curl -XGEThttp://server:9200/medios/news/_search-d '{ "query" :
{ "term" : { "fuente" : "Avui" } } }'

while in the same time, this works great:

curl -XGEThttp://server:9200/medios/news/_search?q=fuente:Avui

I am quite sure that is should be something obvious but ... can't
figure it out :frowning:

I think the parameter q=fuente:Avui is equivalent to

{ "query":
{ "query_string":
{ "query": "fuente:Avui"
}
}

}

The "query_string" is parsed (and analyzed) into something very close to
your attempt:

{ "query": { "term" : { "fuente": "avui" } } }

My conjecture is that when "fuente:Avui" is parsed, the term "Avui" is
normalized to lowercase as "avui" โ€“ this should be the same which happens
when you index your documents (because the default query analyzer matches
the default index analyzer). So the "query_string" works ok, but not your
"term" query because that one does not analyze "Avui" and then you have no
match for this term with an uppercase letter "A".

So I suggest you try "avui" in lowercase at the "term" query. And probably
someone else in the list may confirm if I got that right.