Elastic Search (Query)


(sweta k) #1

What is the Query to Search a String in Elastic search , When i
disable _all and _source Properties .


(Karussell) #2

E.g. use the text query and specify the field (here 'description')

curl -XPOST http://localhost:9200/ -d '{
"query": {
"text" : { "description" : "Some query here" }
}}'

Regards,
Peter.

On 25 Nov., 12:21, sweta k shwete...@gmail.com wrote:

What is the Query to Search a String in Elastic search , When i
disable _all and _source Properties .


(sweta k) #3

I unable to Search the String ,
This is my Mapping:
curl -XPUT localhost:9200/smit/default_map/_mapping -d '
{
"default_map": {
"_all": {"enabled": false},
"_source" : {"enabled" : false},
"properties": {
"text": {
"type": "string",
"fields": {
"text": {
"store": "yes"}}}
}
}
}'

Now Wen I search I m Unable to Get the String ... , For this Mapping i
Shld be Able To Search the String As i Have Given "Store= yes" ...

On Nov 26, 4:39 am, Karussell tableyourt...@googlemail.com wrote:

E.g. use the text query and specify the field (here 'description')

curl -XPOSThttp://localhost:9200/-d '{
"query": {
"text" : { "description" : "Some query here" }

}}'

Regards,
Peter.

On 25 Nov., 12:21, sweta k shwete...@gmail.com wrote:

What is the Query to Search a String in Elastic search , When i
disable _all and _source Properties .


(Kartavya) #4

try to get actual mapping using

curl -XGET 'localh0st:9200/smit/default_map/_mapping'

Regards,
Pulkit Agrawal

On Tue, Nov 29, 2011 at 11:37 AM, sweta k shwetest1@gmail.com wrote:

I unable to Search the String ,
This is my Mapping:
curl -XPUT localhost:9200/smit/default_map/_mapping -d '
{
"default_map": {
"_all": {"enabled": false},
"_source" : {"enabled" : false},
"properties": {
"text": {
"type": "string",
"fields": {
"text": {
"store": "yes"}}}
}
}
}'

Now Wen I search I m Unable to Get the String ... , For this Mapping i
Shld be Able To Search the String As i Have Given "Store= yes" ...

On Nov 26, 4:39 am, Karussell tableyourt...@googlemail.com wrote:

E.g. use the text query and specify the field (here 'description')

curl -XPOSThttp://localhost:9200/-d '{
"query": {
"text" : { "description" : "Some query here" }

}}'

Regards,
Peter.

On 25 Nov., 12:21, sweta k shwete...@gmail.com wrote:

What is the Query to Search a String in Elastic search , When i
disable _all and _source Properties .


(Shay Banon) #5

What is your search request? Note, you need to specify a default field to
search against if you disable _all.

On Tue, Nov 29, 2011 at 8:07 AM, sweta k shwetest1@gmail.com wrote:

I unable to Search the String ,
This is my Mapping:
curl -XPUT localhost:9200/smit/default_map/_mapping -d '
{
"default_map": {
"_all": {"enabled": false},
"_source" : {"enabled" : false},
"properties": {
"text": {
"type": "string",
"fields": {
"text": {
"store": "yes"}}}
}
}
}'

Now Wen I search I m Unable to Get the String ... , For this Mapping i
Shld be Able To Search the String As i Have Given "Store= yes" ...

On Nov 26, 4:39 am, Karussell tableyourt...@googlemail.com wrote:

E.g. use the text query and specify the field (here 'description')

curl -XPOSThttp://localhost:9200/-d '{
"query": {
"text" : { "description" : "Some query here" }

}}'

Regards,
Peter.

On 25 Nov., 12:21, sweta k shwete...@gmail.com wrote:

What is the Query to Search a String in Elastic search , When i
disable _all and _source Properties .


(arta) #6

Note, you need to specify a default field to search against if you disable _all.

I'm having the same problem. After I disabled _all, search queries returns 0 hits, except for match_all query.

Here's my mapping:
curl -XGET 'http://localhost:9200/topic1/_mapping'

{
"topic1":{
"DefaultType":{
"_source":{"compress":true},
"properties":{
"content":{"type":"string"},
"time_modified":{"format":"dateOptionalTime","type":"date"}
},
"_all":{"enabled":false}
}
}
}

Any query like this does not hit:

curl -XGET 'http://localhost:9200/topic1/_search'
-d '{ "query" : { "wildcard" : { "default_field" : "content", "query" : "*" }}}'

{
"took":2,
"timed_out":false,
"_shards":{"total":5,"successful":5,"failed":0},
"hits":{"total":0,"max_score":null,"hits":[]}
}

Except for match_all. this hits:

curl -XGET 'http://localhost:9200/topic1/_search?size=1' -d '{ "query" : { "match_all" : { }}}'

{ some result }

Thanks for your help.


(Shay Banon) #7

Can you gist a full recreation? See http://www.elasticsearch.org/help.

On Tue, Dec 20, 2011 at 1:58 AM, arta artasano@sbcglobal.net wrote:

Note, you need to specify a default field to search against if you
disable
_all.

I'm having the same problem. After I disabled _all, search queries returns
0
hits, except for match_all query.

Here's my mapping:
curl -XGET 'http://localhost:9200/topic1/_mapping'

{
"topic1":{
"DefaultType":{
"_source":{"compress":true},
"properties":{
"content":{"type":"string"},
"time_modified":{"format":"dateOptionalTime","type":"date"}
},
"_all":{"enabled":false}
}
}
}

Any query like this does not hit:

curl -XGET 'http://localhost:9200/topic1/_search'
-d '{ "query" : { "wildcard" : { "default_field" : "content", "query" :
"*"
}}}'

{
"took":2,
"timed_out":false,
"_shards":{"total":5,"successful":5,"failed":0},
"hits":{"total":0,"max_score":null,"hits":[]}
}

Except for match_all. this hits:

curl -XGET 'http://localhost:9200/topic1/_search?size=1' -d '{ "query" : {
"match_all" : { }}}'

{ some result }

Thanks for your help.

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3599932.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(arta) #8

Thanks, Shay.
It is gist: 1502438.


(Shay Banon) #9

I added a comment there. You use term query that does not really use
default_field.

On Tue, Dec 20, 2011 at 7:39 PM, arta artasano@sbcglobal.net wrote:

Thanks, Shay.
It is gist: 1502438.

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3601831.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(arta) #10

Follow up:
Seems like "default_field" does not work with most of queries regardless _all is disabled or not.
Hope this helps.


(arta) #11

You use term query that does not really use default_field.

Then how can I search when _all is disabled?


(Shay Banon) #12

default_field applies only for the query_string query, all the other
queries simply require you to specify the field to search on (like term
query).

On Tue, Dec 20, 2011 at 10:18 PM, arta artasano@sbcglobal.net wrote:

You use term query that does not really use default_field.

Then how can I search when _all is disabled?

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3602200.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(arta) #13

I see now. Thank you so much for clearing it out.
It turned out I did wrong at the first place when I tried to disable _all. I used Java API and mistakingly did like this:
client.admin().indices().preparePutMapping("index1").setType("type1").setSource("{"_all": {"enabled": false }}").execute()
I thought I didn't need to give the type name again in the source because it was given to setType(). But it was not correct. (right?)
Because of this mistake, I was not able to hit any query, so I came to this page and saw your response mentioning about 'default field'.
Anyway, the problem solved.
Thanks again.


(system) #14