Newbie Q

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Newbie Q

Svet
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 :-(

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: Newbie Q

Rich Kroll

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" <[hidden email]> wrote:
Reply | Threaded
Open this post in threaded view
|

Re: Newbie Q

Adriano Ferreira
In reply to this post by Svet


On Wed, Jan 12, 2011 at 2:11 PM, Svet <[hidden email]> 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 :-(

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.



Reply | Threaded
Open this post in threaded view
|

Re: Newbie Q

Clinton Gormley

>
> 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


Reply | Threaded
Open this post in threaded view
|

Re: Newbie Q

Svet
In reply to this post by Adriano Ferreira
Indeed, this was the problem. Thank you @Rich, @Adriano, @Clinton!

On 12 ene, 17:39, Adriano Ferreira <[hidden email]> wrote:

> On Wed, Jan 12, 2011 at 2:11 PM, Svet <[hidden email]> 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 :-(
>
> 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.