mbaker
(mbaker)
January 5, 2015, 10:09pm
1
I would like to sort the results of a query such that all of the records
with a value of true in the expires field will be at the top. I am not
using relevance for sorting. I tried adding this as a sort, but it doesn't
seem to work with either sorting order: { expires: { order: "desc" } }
All of the records are in the result but they aren't sorted. Is there a
different way I should be going about this?
For reference, here is my entire query:
{
"query": {
"match_all": {
}
},
"size": 50,
"from": 0,
"fields": [
"id"
],
"sort": [
{
"expires": {
"order": "desc"
}
}
]
}
--
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/0bfc5579-8855-44a8-97e3-58ede3bb10d4%40googlegroups.com .
For more options, visit https://groups.google.com/d/optout .
dadoonet
(David Pilato)
January 6, 2015, 6:34am
2
I think sorting on boolean should work.
If you can't make it working, you could also use function_score to "boost" expires:true vs expires:false.
HTH
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 5 janv. 2015 à 23:09, mbaker@trunkclub.com a écrit :
I would like to sort the results of a query such that all of the records with a value of true in the expires field will be at the top. I am not using relevance for sorting. I tried adding this as a sort, but it doesn't seem to work with either sorting order: { expires: { order: "desc" } }
All of the records are in the result but they aren't sorted. Is there a different way I should be going about this?
For reference, here is my entire query:
{
"query": {
"match_all": {
}
},
"size": 50,
"from": 0,
"fields": [
"id"
],
"sort": [
{
"expires": {
"order": "desc"
}
}
]
}
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/0bfc5579-8855-44a8-97e3-58ede3bb10d4%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/BB982DA5-E7BF-4E23-AC76-CDC2C10CDE7B%40pilato.fr .
For more options, visit https://groups.google.com/d/optout .
Joao_Nelas
(Joao Nelas)
January 11, 2015, 4:40pm
3
No, I don't think sorting on booleans works. At least I've had no luck with
it.
On Tuesday, January 6, 2015 at 6:34:52 AM UTC, David Pilato wrote:
I think sorting on boolean should work.
If you can't make it working, you could also use function_score to "boost"
expires:true vs expires:false.
HTH
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 5 janv. 2015 à 23:09, mba...@trunkclub.com <javascript:> a écrit :
I would like to sort the results of a query such that all of the records
with a value of true in the expires field will be at the top. I am not
using relevance for sorting. I tried adding this as a sort, but it doesn't
seem to work with either sorting order: { expires: { order: "desc" } }
All of the records are in the result but they aren't sorted. Is there a
different way I should be going about this?
For reference, here is my entire query:
{
"query": {
"match_all": {
}
},
"size": 50,
"from": 0,
"fields": [
"id"
],
"sort": [
{
"expires": {
"order": "desc"
}
}
]
}
--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0bfc5579-8855-44a8-97e3-58ede3bb10d4%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/0bfc5579-8855-44a8-97e3-58ede3bb10d4%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/68ead506-a232-43ba-9f16-b5d933132de7%40googlegroups.com .
For more options, visit https://groups.google.com/d/optout .
dadoonet
(David Pilato)
January 12, 2015, 8:44am
4
I just tried this with elasticsearch 1.4.2:
DELETE test
PUT test/doc/1
{
"foo": true
}
PUT test/doc/2
{
"foo": false
}
Gives doc 2 first
GET test/_search
{
"sort": [
{
"foo": {
"order": "asc"
}
}
]
}
Gives doc 1 first
GET test/_search
{
"sort": [
{
"foo": {
"order": "desc"
}
}
]
}
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfr https://twitter.com/elasticsearchfr | @scrutmydocs https://twitter.com/scrutmydocs
Le 11 janv. 2015 à 17:40, Joao Nelas joao.nelas@gmail.com a écrit :
No, I don't think sorting on booleans works. At least I've had no luck with it.
On Tuesday, January 6, 2015 at 6:34:52 AM UTC, David Pilato wrote:
I think sorting on boolean should work.
If you can't make it working, you could also use function_score to "boost" expires:true vs expires:false.
HTH
--
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 5 janv. 2015 à 23:09, mba...@trunkclub.com <javascript:> a écrit :
I would like to sort the results of a query such that all of the records with a value of true in the expires field will be at the top. I am not using relevance for sorting. I tried adding this as a sort, but it doesn't seem to work with either sorting order: { expires: { order: "desc" } }
All of the records are in the result but they aren't sorted. Is there a different way I should be going about this?
For reference, here is my entire query:
{
"query": {
"match_all": {
}
},
"size": 50,
"from": 0,
"fields": [
"id"
],
"sort": [
{
"expires": {
"order": "desc"
}
}
]
}
--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0bfc5579-8855-44a8-97e3-58ede3bb10d4%40googlegroups.com https://groups.google.com/d/msgid/elasticsearch/0bfc5579-8855-44a8-97e3-58ede3bb10d4%40googlegroups.com?utm_medium=email&utm_source=footer .
For more options, visit https://groups.google.com/d/optout 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 mailto:elasticsearch+unsubscribe@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/68ead506-a232-43ba-9f16-b5d933132de7%40googlegroups.com https://groups.google.com/d/msgid/elasticsearch/68ead506-a232-43ba-9f16-b5d933132de7%40googlegroups.com?utm_medium=email&utm_source=footer .
For more options, visit https://groups.google.com/d/optout 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/998FB640-5163-4426-8911-5FB705B3D857%40pilato.fr .
For more options, visit https://groups.google.com/d/optout .
1 Like