James_Moss  
                (James Moss)
               
                 
              
                  
                    September 22, 2014,  2:38pm
                   
                   
              1 
               
             
            
              Hi,
I need to pull out a random selection of documents (based on a seed) and 
then make that set sortable but I'm having difficulties:
Here's what I've got at the moment, I'm trying to pull out a random 
selection of document (real estate properties) and then sort them by price 
desc:
GET _search 
{ 
"from": 0, 
"size": 30, 
"query": { 
"function_score": { 
"query": { 
"filtered": { 
"query": { 
"match_all": {} 
}, 
"filter": { 
"and": [ 
{ 
"term": { 
"property.rental": 0 
} 
}, 
{ 
"term": { 
"property.status": 100 
} 
} 
] 
} 
} 
}, 
"random_score": { 
"seed": 124567 
} 
} 
}, 
"sort": [ 
{ 
"property.price": "desc" 
} 
], 
"filter": { 
"range": { 
"property.price": { 
"gte": 500000 
} 
} 
} 
}
It seems the sort is being applied to all the documents in the index, not 
just those returned from the query.
Is this even possible with elasticsearch?
-- 
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/b82ba776-854b-4649-bd71-2719cf095061%40googlegroups.com . 
For more options, visit https://groups.google.com/d/optout .
             
            
               
               
               
            
            
           
          
            
            
              No, it is just that sort is overriding the random_score. I would say just 
do the sorting on the client side - while it is possible to do still on ES 
(using scripted fields for example) it will just get too complicated.
--
Itamar Syn-Hershko 
http://code972.com  | @synhershko  https://twitter.com/synhershko  
Freelance Developer & Consultant 
Author of RavenDB in Action http://manning.com/synhershko/ 
On Mon, Sep 22, 2014 at 5:38 PM, James Moss email@jamesmoss.co.uk  wrote:
Hi,
I need to pull out a random selection of documents (based on a seed) and 
then make that set sortable but I'm having difficulties:
Here's what I've got at the moment, I'm trying to pull out a random 
selection of document (real estate properties) and then sort them by price 
desc:
GET _search 
{ 
"from": 0, 
"size": 30, 
"query": { 
"function_score": { 
"query": { 
"filtered": { 
"query": { 
"match_all": {} 
}, 
"filter": { 
"and": [ 
{ 
"term": { 
"property.rental": 0 
} 
}, 
{ 
"term": { 
"property.status": 100 
} 
} 
] 
} 
} 
}, 
"random_score": { 
"seed": 124567 
} 
} 
}, 
"sort": [ 
{ 
"property.price": "desc" 
} 
], 
"filter": { 
"range": { 
"property.price": { 
"gte": 500000 
} 
} 
} 
}
It seems the sort is being applied to all the documents in the index, not 
just those returned from the query.
Is this even possible with elasticsearch?
-- 
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/b82ba776-854b-4649-bd71-2719cf095061%40googlegroups.com  
https://groups.google.com/d/msgid/elasticsearch/b82ba776-854b-4649-bd71-2719cf095061%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/CAHTr4Zu%2BmVGBznf%3Dcst0C%2B8RWRSDRrmPnbE-dg4Awno5EB84Wg%40mail.gmail.com . 
For more options, visit https://groups.google.com/d/optout .