Elastic Search (Query)

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

Elastic Search (Query)

sweta k
What is the Query to Search a String in Elastic search , When i
disable _all and _source Properties .
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

Karussell
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 <[hidden email]> wrote:
> What is the Query to Search a String in Elastic search , When i
> disable _all and _source Properties .
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

sweta k
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 <[hidden email]> 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 <[hidden email]> wrote:
>
>
>
>
>
>
>
> > What is the Query to Search a String in Elastic search , When i
> > disable _all and _source Properties .
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

Kartavya
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > What is the Query to Search a String in Elastic search , When i
>> > disable _all and _source Properties .
>
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

kimchy
Administrator
In reply to this post by sweta k
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> wrote:
>
>
>
>
>
>
>
> > What is the Query to Search a String in Elastic search , When i
> > disable _all and _source Properties .

Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

arta
> 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.
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

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

On Tue, Dec 20, 2011 at 1:58 AM, arta <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

arta
Thanks, Shay.
It is gist: 1502438.
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

kimchy
Administrator
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 <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

arta
In reply to this post by arta
Follow up:
Seems like "default_field" does not work with most of queries regardless _all is disabled or not.
Hope this helps.
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

arta
> You use `term` query that does not really use `default_field`.

Then how can I search when _all is disabled?
Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

kimchy
Administrator
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 <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

Re: Elastic Search (Query)

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