Elastic search : Quesry not executing


(ravi kumar) #1

Here is mapping of my elastic search

{"MYAPP":{"mappings":{
"XX":{
"_ttl":{"enabled":true},
"properties":{"propX":{"type":"integer"}}
},
"YY":{
"_ttl":{"enabled":true},
"properties":{"propY":{"type":"integer"}}
},
}
}
}

I want execute query like propX:XYZ AND propY:ABC

The problem is if i do this

propX:XYZ AND propY:ABC

It return nothing, but this

propX:XYZ

return result. I think the problem is propX and propY are two different
region thats why using both returns nothing.

Here is my JAVA code:

SearchResponse response = client.prepareSearch("MYAPP")
.setQuery(QueryBuilders.queryString("propX:XYZ AND propY:ABC")).execute()
.actionGet();

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/353a5e38-a31d-487d-bc56-9625d77ec6e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(vineeth mohan-2) #2

Hello Ravi ,

Can you provide some data indexed.
Is can be possible that propY:ABC value doesn't exist and the AND gave a
null set.

Thanks
Vineeth

On Mon, Sep 1, 2014 at 2:55 AM, ravi kumar ravi43807@gmail.com wrote:

Here is mapping of my elastic search

{"MYAPP":{"mappings":{
"XX":{
"_ttl":{"enabled":true},
"properties":{"propX":{"type":"integer"}}
},
"YY":{
"_ttl":{"enabled":true},
"properties":{"propY":{"type":"integer"}}
},
}
}
}

I want execute query like propX:XYZ AND propY:ABC

The problem is if i do this

propX:XYZ AND propY:ABC

It return nothing, but this

propX:XYZ

return result. I think the problem is propX and propY are two different
region thats why using both returns nothing.

Here is my JAVA code:

SearchResponse response = client.prepareSearch("MYAPP")
.setQuery(QueryBuilders.queryString("propX:XYZ AND propY:ABC")).execute()
.actionGet();

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/353a5e38-a31d-487d-bc56-9625d77ec6e2%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/353a5e38-a31d-487d-bc56-9625d77ec6e2%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3Ds6Ek4wtmBHYQd9-Q8t_RK8GgyvKG-76qK1H%3DHO1x_AA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(ravi kumar) #3

Here is the sample data

"hits" : [

{
"_index" : "myIndex",
"_type" : "sellItemsIndices",
"_id" : "4ks8w",
"_score" : 1.0,
"_source":{"sellAdState":"Karnataka"}
}

{
"_index" : "myIndex",
"_type" : "laptopIndices",
"_id" : "4ks8w",
"_score" : 1.0,
"_source":{"laptopModelId":"Vostro"}
}

now i want to execute below query

laptopModelId:"Vostro" AND sellAdState:"Karnataka"

Here is the java code that returns nothing

    SearchResponse response = client.prepareSearch("myIndex")
    .setTypes("laptopIndices","sellItemsIndices")
    .setQuery(QueryBuilders.queryString("laptopModelId:\"Vostro\" AND sellAdState:\"Karnataka\""))
    .execute()
    .actionGet();  

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e3c964d3-bb12-4c2f-8429-715c6457b913%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(ravi kumar) #4

Here is the sample data

"hits" : [

{
"_index" : "myIndex",
"_type" : "sellItemsIndices",
"_id" : "4ks8w",
"_score" : 1.0,
"_source":{"sellAdState":"Karnataka"}
}

{
"_index" : "myIndex",
"_type" : "laptopIndices",
"_id" : "4ks8w",
"_score" : 1.0,
"_source":{"laptopModelId":"Vostro"}
}

now i want to execute below query

laptopModelId:"Vostro" AND sellAdState:"Karnataka"

Here is the java code that returns nothing

    SearchResponse response = client.prepareSearch("myIndex")
    .setTypes("laptopIndices","sellItemsIndices")
    .setQuery(QueryBuilders.queryString("laptopModelId:\"Vostro\" AND sellAdState:\"Karnataka\""))
    .execute()
    .actionGet();

One more thing is there some limitation or performance issue if I add large number of field in _source

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fc59d51c-5424-483c-9992-5a003614f815%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #5

You don't have any document which have both values.
Try with
laptopModelId:"Vostro" sellAdState:"Karnataka"

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 1 sept. 2014 à 07:01, ravi kumar ravi43807@gmail.com a écrit :

Here is the sample data
"hits" : [

{
"_index" : "myIndex",
"_type" : "sellItemsIndices",
"_id" : "4ks8w",
"_score" : 1.0,
"_source":{"sellAdState":"Karnataka"}
}

{
"_index" : "myIndex",
"_type" : "laptopIndices",
"_id" : "4ks8w",
"_score" : 1.0,
"_source":{"laptopModelId":"Vostro"}
}

now i want to execute below query

laptopModelId:"Vostro" AND sellAdState:"Karnataka"

Here is the java code that returns nothing

    SearchResponse response = client.prepareSearch("myIndex")
    .setTypes("laptopIndices","sellItemsIndices")
    .setQuery(QueryBuilders.queryString("laptopModelId:\"Vostro\" AND sellAdState:\"Karnataka\""))
    .execute()
    .actionGet();

One more thing is there some limitation or performance issue if I add large number of field in _source

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fc59d51c-5424-483c-9992-5a003614f815%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/BE79C210-D6D3-4D7E-9991-C459AE3E47F2%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.


(ravi kumar) #6

Hi david ,

Your query is working but thats not what I want. What i want is to return
record of laptop that with laptopModelId "Vostro" AND sellAdState should be
"Karnataka".

Shall I change my data schema and make it in under same _type ?

I have around 70-80 fields. will it be efficient to put all these fields
inside same _type so that

laptopModelId:"Vostro" AND sellAdState:"Karnataka"

can be executed?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3cee85cf-8350-4baa-9d38-298f33a9982f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(ravi kumar) #7

Hi david ,

Your query is working but thats not what I want. What i want is to return
record of laptop that with laptopModelId "Vostro" AND sellAdState should be
"Karnataka".

laptopModelId and sellAdState will always be under different _types.

Shall I change my data schema and make it in under same _type ?

I have around 70-80 fields. will it be efficient to put all these fields
inside same _type so that

laptopModelId:"Vostro" AND sellAdState:"Karnataka"

can be executed?

or Is there any other solution to my previous given data format?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/684f82b8-4990-45bc-bb37-2331b187c82f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #8

Yes.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 1 sept. 2014 à 08:53, ravi kumar ravi43807@gmail.com a écrit :

Hi david ,

Your query is working but thats not what I want. What i want is to return record of laptop that with laptopModelId "Vostro" AND sellAdState should be "Karnataka".

Shall I change my data schema and make it in under same _type ?

I have around 70-80 fields. will it be efficient to put all these fields inside same _type so that

laptopModelId:"Vostro" AND sellAdState:"Karnataka"

can be executed?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3cee85cf-8350-4baa-9d38-298f33a9982f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/02F124E1-5473-4E92-9281-895E85158E86%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.


(Bharvi Dixit-2) #9

Hi Ravi,

You need to change your schema & put all these fields under same type to
get the output. And as per my experience with elasticsearch ther won't be
any problem with large the number of fields.

Regards
Bharvi

On Monday, 1 September 2014 12:25:36 UTC+5:30, ravi kumar wrote:

Hi david ,

Your query is working but thats not what I want. What i want is to return
record of laptop that with laptopModelId "Vostro" AND sellAdState should be
"Karnataka".

laptopModelId and sellAdState will always be under different _types.

Shall I change my data schema and make it in under same _type ?

I have around 70-80 fields. will it be efficient to put all these fields
inside same _type so that

laptopModelId:"Vostro" AND sellAdState:"Karnataka"

can be executed?

or Is there any other solution to my previous given data format?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/757959af-81c1-423b-8526-e06037113120%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(ravi kumar) #10

Hi Dixit ,

SO will it be ok to put 1000s fields inside the same _type. This is what i
am worry about

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f284fc0d-b516-4ee9-832c-2484ea229513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(ravi kumar) #11

Hi Dixit ,

SO will it be ok to put 1000s fields inside the same _type. This is what i
am worry about. Is there any docs that describe this kind of limitation

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/71e1e3f3-7a3b-4c1b-932a-8b752f52882a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(vineeth mohan-2) #12

Hello Ravi ,

Its not a good practice to add any number of fields , this will have a toll
on the performance.

Instead of storing it as laptopModelId:"Vostro" ,

Store it as

"attributes" : [{
"key" : laptopModelId",
"value" : "Vostro"
},
{
"key" ...
"value" ...
}]

And then declare attributes as nested type.

Thanks
Vineeth

On Mon, Sep 1, 2014 at 1:04 PM, ravi kumar ravi43807@gmail.com wrote:

Hi Dixit ,

SO will it be ok to put 1000s fields inside the same _type. This is what i
am worry about. Is there any docs that describe this kind of limitation

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/71e1e3f3-7a3b-4c1b-932a-8b752f52882a%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/71e1e3f3-7a3b-4c1b-932a-8b752f52882a%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nPi_B9KOaO3trrjgUDZE_J%2BMnZ2B%3DsJUQvyT0jAuug5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Jörg Prante) #13

There is no limitation on fields in ES. Each field requires a bit of memory
so the limit is only dependent on your hardware resources (RAM, CPU power).

I run ~1000 fields if it is of any interest, without significant
performance hit.

Jörg

On Mon, Sep 1, 2014 at 9:34 AM, ravi kumar ravi43807@gmail.com wrote:

Hi Dixit ,

SO will it be ok to put 1000s fields inside the same _type. This is what i
am worry about. Is there any docs that describe this kind of limitation

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/71e1e3f3-7a3b-4c1b-932a-8b752f52882a%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/71e1e3f3-7a3b-4c1b-932a-8b752f52882a%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH0EUPE4Ex%2BvoU-u5mxYbcsQJ0Z-eEA5Ghprv1Todta9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #14