Help with "bool" and "prefix" query in url

Hi, should a query specified by a "json" body also be able to be sent
via the url only? E.g. this query works fine:

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix: {"name":
"hello"}}]}}}'

but I would like to convert it to a GET with only a url, no body.

I'm looking at http://www.elasticsearch.org/guide/reference/api/search/uri-request.html
and can do this query, but don't understand how to specify a "prefix"
query or how to specify the "bool" (and?) query.

curl -XGET 'localhost:9200/_search?pretty=yes&q=context:example.com/
mybucket&q=hello%20world.html'

Thanks,
Jamshid

On Aug 2, 3:38 pm, Jamshid jamshi...@gmail.com wrote:

Hi, should a query specified by a "json" body also be able to be sent
via the url only? [...]

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix: {"name":
"hello"}}]}}}'

Oh I'm so close, but it seems like default_operator doesn't do what I
think it does.

I want all docs where "context" is "example.com/mybucket" and "name"
begins with "var".

This query returns documents matching either, even though I specify
"default_operator=AND".

curl -i -XGET 'localhost:9200/_search?
pretty=yes&default_operator=AND&q=context:example.com/
mybucket&q=name:var*'
...
"_source" : { "mytype" : { "name" : "var/hello.html", "context" :
"example.com/mybucket" } }
"_source" : { "mytype" : { "name" : "var/hello.html", "context" :
"example2.com/mybucket"} }

I know elasticsearch "sees" "default_operator", because it complains
if I give it a garbage value. Any idea what I'm doing wrong?

Actually one thing wrong is that I'm using multiple "q" query args --
all but the last are ignored.

Thanks,
Jamshid

Doh, ok the syntax for url queries is similar to Solr / Lucene syntax.
To get a url-only query like this:

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix: {"name":
"var"}}]}}}'

I need to set the "q" query arg to the url-encoded string
"context:example.com/mybucket name:var*", and I need to set the
default_operator to AND:

curl -XGET 'localhost:9200/_search?
pretty=yes&default_operator=AND&q=context:example.com/mybucket
%20name:var*'

Hope this helps someone else.

Maybe an example like this could be added to
http://www.elasticsearch.org/guide/reference/api/search/uri-request.html
or enable comments and I'll mention it.

Thanks,
Jamshid

Another option is to provide the json body request in the uri, if you
want... .

On Thu, Aug 4, 2011 at 12:03 PM, Jamshid jamshid69@gmail.com wrote:

Doh, ok the syntax for url queries is similar to Solr / Lucene syntax.
To get a url-only query like this:

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix: {"name":
"var"}}]}}}'

I need to set the "q" query arg to the url-encoded string
"context:example.com/mybucket name:var*", and I need to set the
default_operator to AND:

curl -XGET 'localhost:9200/_search?
pretty=yes&default_operator=AND&q=context:example.com/mybucket
%20name:var*'

Hope this helps someone else.

Maybe an example like this could be added to
Elasticsearch Platform — Find real-time answers at scale | Elastic
or enable comments and I'll mention it.

Thanks,
Jamshid

Sorry not sure what you mean, can an arbitrary json body instead be
url encoded and used as a query string argument, so that the GET
request's Content-length is 0?

What is the name of the query string argument?

Thanks,
Jamshid

On Aug 4, 12:53 pm, Shay Banon kim...@gmail.com wrote:

Another option is to provide the json body request in the uri, if you
want... .

On Thu, Aug 4, 2011 at 12:03 PM, Jamshid jamshi...@gmail.com wrote:

Doh, ok the syntax for url queries is similar to Solr / Lucene syntax.
To get a url-only query like this:

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix: {"name":
"var"}}]}}}'

I need to set the "q" query arg to the url-encoded string
"context:example.com/mybucket name:var*", and I need to set the
default_operator to AND:

curl -XGET 'localhost:9200/_search?
pretty=yes&default_operator=AND&q=context:example.com/mybucket
%20name:var*'

Hope this helps someone else.

Maybe an example like this could be added to
Elasticsearch Platform — Find real-time answers at scale | Elastic
or enable comments and I'll mention it.

Thanks,
Jamshid

Does anyone know the answer to Jamshid's question above? This is the exact
problem I'm trying to figure out. Putting the JSON body in the URI doesn't
seem to work with _percolate. Or maybe I'm not encoding it right?

On Tuesday, August 9, 2011 4:31:06 PM UTC-4, Jamshid wrote:

Sorry not sure what you mean, can an arbitrary json body instead be
url encoded and used as a query string argument, so that the GET
request's Content-length is 0?

What is the name of the query string argument?

Thanks,
Jamshid

On Aug 4, 12:53 pm, Shay Banon kim...@gmail.com wrote:

Another option is to provide the json body request in the uri, if you
want... .

On Thu, Aug 4, 2011 at 12:03 PM, Jamshid jamshi...@gmail.com wrote:

Doh, ok the syntax for url queries is similar to Solr / Lucene syntax.
To get a url-only query like this:

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix: {"name":
"var"}}]}}}'

I need to set the "q" query arg to the url-encoded string
"context:example.com/mybucket name:var*", and I need to set the
default_operator to AND:

curl -XGET 'localhost:9200/_search?
pretty=yes&default_operator=AND&q=context:example.com/mybucket
%20name:var*'

Hope this helps someone else.

Maybe an example like this could be added to

Elasticsearch Platform — Find real-time answers at scale | Elastic

or enable comments and I'll mention it.

Thanks,
Jamshid

It's possible to specify JSON query in the "source" parameter of the
.../_search URL. However, there is no such support for .../_percolate.

On Friday, April 27, 2012 10:53:41 AM UTC-4, jschelle wrote:

Does anyone know the answer to Jamshid's question above? This is the exact
problem I'm trying to figure out. Putting the JSON body in the URI doesn't
seem to work with _percolate. Or maybe I'm not encoding it right?

On Tuesday, August 9, 2011 4:31:06 PM UTC-4, Jamshid wrote:

Sorry not sure what you mean, can an arbitrary json body instead be
url encoded and used as a query string argument, so that the GET
request's Content-length is 0?

What is the name of the query string argument?

Thanks,
Jamshid

On Aug 4, 12:53 pm, Shay Banon kim...@gmail.com wrote:

Another option is to provide the json body request in the uri, if you
want... .

On Thu, Aug 4, 2011 at 12:03 PM, Jamshid jamshi...@gmail.com wrote:

Doh, ok the syntax for url queries is similar to Solr / Lucene
syntax.
To get a url-only query like this:

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix:
{"name":
"var"}}]}}}'

I need to set the "q" query arg to the url-encoded string
"context:example.com/mybucket name:var*", and I need to set the
default_operator to AND:

curl -XGET 'localhost:9200/_search?
pretty=yes&default_operator=AND&q=context:example.com/mybucket
%20name:var*'

Hope this helps someone else.

Maybe an example like this could be added to

Elasticsearch Platform — Find real-time answers at scale | Elastic

or enable comments and I'll mention it.

Thanks,
Jamshid

Hi kimchy, could you provide an example, I do not understand "provide the
json body in the request uri"

regards

On Thursday, August 4, 2011 1:23:10 PM UTC-4:30, kimchy wrote:

Another option is to provide the json body request in the uri, if you
want... .

On Thu, Aug 4, 2011 at 12:03 PM, Jamshid jamshid69@gmail.com wrote:

Doh, ok the syntax for url queries is similar to Solr / Lucene syntax.
To get a url-only query like this:

curl -XGET 'localhost:9200/_search?pretty=yes' -d '{query: {bool:
{must: [{term: {"context": "example.com/mybucket"}},{prefix: {"name":
"var"}}]}}}'

I need to set the "q" query arg to the url-encoded string
"context:example.com/mybucket name:var*", and I need to set the
default_operator to AND:

curl -XGET 'localhost:9200/_search?
pretty=yes&default_operator=AND&q=context:example.com/mybucket
%20name:var*'

Hope this helps someone else.

Maybe an example like this could be added to
Elasticsearch Platform — Find real-time answers at scale | Elastic
or enable comments and I'll mention it.

Thanks,
Jamshid