Check if nested object not exists

2015-01-13 Thread Elke
Hello.

I want to check if an document miss a nested object (and the opposite too). 
I want to get all documents which contain a marketplace that does not have 
a price array. 
This is part of my query (there are "and filter" because there can be more 
than one restriction) :

 {
   "nested": {
   "filter": {
   "and": {
   "filters": [,{
   "nested": {
   "filter": {
   "and": {
   "filters": [
   {
   
"not": {
   
"filter": {
   
"exists": {

   
"field": "marketplace.price.id"
   
}
   }
   }
   }
   ]
   }
   },
   "path": 
"marketplace.price"
   }
   }
   ]
   }
   },
   "path": "marketplace"
   }
   }

both marketplace and price are mapped : "nested".

I have two marketplaces. One has a price array, one does not have a price 
array. In the same document. With the query above I don't get a hit.

Can someone give me a hint or solution for that problem?

Cheers,
Elke


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/fd9b38a2-8bd1-4175-ace1-588917056dfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sorting by nested fields

2014-12-10 Thread Elke
Is this possible using script sort?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/5cdb92cb-676d-45dc-b242-ff9865a3129e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sorting by nested fields

2014-10-17 Thread Elke
Has somebody another idea? Or it is not possible at all?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/d1748088-0ceb-409d-9e42-deffa314f0e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem in search nested type object

2014-10-16 Thread Elke
Hi.

What kind of analyzer do you use? I think it might be a problem with the 
whitespace (Or do you have the same problem if the value does not contain 
whitespaces?). 
In this case you can use a keyword analyzer (so you will not separate the 
words into single token) or map the fields to not_analyzed.





Am Donnerstag, 16. Oktober 2014 12:59:13 UTC+2 schrieb shekhar chauhan:
>
> Hi All,
>   I am facing a problem in searcing a nested object.My document structure 
> is -
>
> {
>"sectionResults": [
>{
>"SectionName": "More Details",
>"itemResults": [
>
>{
>"InspectionItem": "Project Name",
>"ItemInfo": ""
>
>}
>]
>}
>   
>]
> }
>
> and I have used this mapping query to make itemResults object(in document) 
> of nested type - 
> PUT realtek_release_v6_nestedsearch/_mapping
> {
>   "realtek_release_v6_nestedsearch":{
> "properties": {
>   "sectionResults":{
> "type": "object",
> "properties": {
>   "itemResults":{
> "type": "nested"
>   }
> }
>   }
> }
>   }
> }
>
> then i have checked the mapping .In mapping itemResults of nested type. 
> Everything if fine here.
> But problem comes in searching query for nested object.my searching query 
> is - 
>
> "query": {
> "filtered": {
>   "query": {
> "match_all": {}
>   },
>   "filter": {
> "nested": {
>   "path": "sectionResults.itemResults",
>   "filter": {
> "bool": {
>   "must": [ 
> {
>   "term": {
> "itemResults.InspectionItem": "Project Name"
>   }
> }
>   ]
> }
>   }
> }
> }
>   }
> }
>
> this query returns 0 matching results.but result exists in database.I do 
> not know whether i am doing mistake in mapping or search query.Please help.
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/57701159-6000-493b-a0a6-28c054ac22ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sorting by nested fields

2014-10-13 Thread Elke
Hi.

I tried to set the nested_path to "marketplaces" and "marketplaces.prices". 
But I still get "Infinity" as sort result. 

Best regards,
Elke

Am Freitag, 10. Oktober 2014 15:23:50 UTC+2 schrieb Jonathan Foy:
>
> I suspect that because you have multiple levels of nesting you need to use 
> the nested path 
> <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_sorting_within_nested_objects>
>  
> (it's probably choosing marketplaces.prices, and you would want just 
> marketplaces, though I'm not positive).
>
> On Tuesday, October 7, 2014 11:35:37 AM UTC-4, Elke wrote:
>>
>> Hi.
>>
>> I have a question about sorting by nested fields. 
>> This is just an small example of the hierarchy level (The marketplaces 
>> and the prices are mapped as nested documents): 
>>
>> { id: "doc1",
>>   name : "test",
>>   marketplaces : [ { "name" :  "marketPlace1",
>>   "prices" : [ { "amount": "20.00" },
>> {  "amount": "40.00" }]
>> },
>>  { "name" :  "marketPlace2",
>>   "prices" : [{ "amount": "21.00" },
>> { "amount": "30.00" }]
>> }]}
>> 
>> { id: "doc2",
>>   name : "test2",
>>   marketplaces : [ { "name" :  "marketPlace1",
>>   "prices" : [{ "amount": "30.00" },
>> { "amount": "35.00" }]
>> },
>>  { "name" :  "marketPlace2",
>>   "prices" : [{ "amount": "1.00" },
>> { "amount": "3.00" }]
>> }]}
>> 
>> Now I want to search for all documents with the marketplace name : 
>> "marketPlace1" and sort the result by the prices.amount of this 
>> marketplace. 
>> So I expect that in the example the first document will be in first place 
>> and the second document will be in second place. 
>>
>> The filter works fine. I won't see the documents without "marketPlace1" 
>> in the result list. 
>> But the sort doesn't restrict the same as the filter. So I tried to set a 
>> nested filter to match the upper hierarchy too. 
>>
>> I tried this sort, but got the value "Infinity" as sort result. :
>>  "sort" :  {
>> "marketplaces.prices.amount" : { "order" : "asc" , "nested_filter" : 
>> { 
>> "term" : {
>> "marketplaces.name" : 
>> "marketPlace1"
>> 
>>
>> In case I don't use the nested_filter I get the second document as first 
>> result, because the sorting doesn't consider the marketPlace name. 
>> 
>>   
>> Is there a solution for my problem?
>> Thank you very much for your help. 
>>
>> Best regards, 
>> Elke
>>
>>
>>
>> 
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/57395623-eae8-4c02-b0f6-24f3e913f7ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Sorting by nested fields

2014-10-07 Thread Elke
Hi.

I have a question about sorting by nested fields. 
This is just an small example of the hierarchy level (The marketplaces and 
the prices are mapped as nested documents): 

{ id: "doc1",
  name : "test",
  marketplaces : [ { "name" :  "marketPlace1",
  "prices" : [ { "amount": "20.00" },
{  "amount": "40.00" }]
},
 { "name" :  "marketPlace2",
  "prices" : [{ "amount": "21.00" },
{ "amount": "30.00" }]
}]}

{ id: "doc2",
  name : "test2",
  marketplaces : [ { "name" :  "marketPlace1",
  "prices" : [{ "amount": "30.00" },
{ "amount": "35.00" }]
},
 { "name" :  "marketPlace2",
  "prices" : [{ "amount": "1.00" },
{ "amount": "3.00" }]
}]}

Now I want to search for all documents with the marketplace name : 
"marketPlace1" and sort the result by the prices.amount of this 
marketplace. 
So I expect that in the example the first document will be in first place 
and the second document will be in second place. 

The filter works fine. I won't see the documents without "marketPlace1" in 
the result list. 
But the sort doesn't restrict the same as the filter. So I tried to set a 
nested filter to match the upper hierarchy too. 

I tried this sort, but got the value "Infinity" as sort result. :
 "sort" :  {
"marketplaces.prices.amount" : { "order" : "asc" , "nested_filter" : { 
    "term" : {
"marketplaces.name" : "marketPlace1"


In case I don't use the nested_filter I get the second document as first 
result, because the sorting doesn't consider the marketPlace name. 

  
Is there a solution for my problem?
Thank you very much for your help. 

Best regards, 
Elke





-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/589eae79-0041-4947-879a-f9b7829c3145%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.