Problem with sorting results of query with multiple attributes

Hey,
I'm just starting with ElasticSearch now and tried simple index schema :

"mappings" : {
"clip" : {
"properties" : {
"subject" : {
"properties" : {
subjectId: {
index: "analyzed",
type: "integer"
},
insertDate: {
index: "analyzed",
type: "integer"
}
}
}
}
}
}

Then I inserted few clips, some of them with multiple atribute such as :

  • subject: [
    • {
      • subjectId: 4
      • insertDate: 5
        }
    • {
      • subjectId: 3
      • insertDate: 6
        }
        ]

Problem is, when I try to search for clips that got subjectId = 3 and sort
result by insertDate what happens is ES would find
{subjectId=3,insertDate=6} but would sort results using FIRST attribute
(which is (subjectId=4,insertDate=5). So it finally finds data that I want
to find, but sorts them not with the attribute that MATCH to my query but
the first attribute. Is there any chance to fix this one?

Thats my query by the way

{"fields":["_parent","_source"],"query":{"bool":{"must":[{"range":{
"subjectId":{"gte":3,"lte":3}}}],"must_not":[],"should":[]}},"from":0,"size"
:50,"sort":[{"insertDate":{"reverse":false}}],"facets":{},"version":true}

Thanks for checking out

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

What you're looking for are nested objects:

Also see:
*

*

clint

On 18 October 2013 12:37, Szymon Baranowski
szymon.baranowski.pl@gmail.comwrote:

Hey,
I'm just starting with Elasticsearch now and tried simple index schema :

"mappings" : {
"clip" : {
"properties" : {
"subject" : {
"properties" : {
subjectId: {
index: "analyzed",
type: "integer"
},
insertDate: {
index: "analyzed",
type: "integer"
}
}
}
}
}
}

Then I inserted few clips, some of them with multiple atribute such as :

  • subject: [
    • {
      • subjectId: 4
      • insertDate: 5
        }
    • {
      • subjectId: 3
      • insertDate: 6
        }
        ]

Problem is, when I try to search for clips that got subjectId = 3 and sort
result by insertDate what happens is ES would find
{subjectId=3,insertDate=6} but would sort results using FIRST attribute
(which is (subjectId=4,insertDate=5). So it finally finds data that I want
to find, but sorts them not with the attribute that MATCH to my query but
the first attribute. Is there any chance to fix this one?

Thats my query by the way

{"fields":["_parent","_source"],"query":{"bool":{"must":[{"range":{
"subjectId":{"gte":3,"lte":3}}}],"must_not":,"should":}},"from":0,
"size":50,"sort":[{"insertDate":{"reverse":false}}],"facets":{},"version":
true}

Thanks for checking out

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks clint

W dniu piątek, 18 października 2013 12:37:11 UTC+2 użytkownik Szymon
Baranowski napisał:

Hey,
I'm just starting with Elasticsearch now and tried simple index schema :

"mappings" : {
"clip" : {
"properties" : {
"subject" : {
"properties" : {
subjectId: {
index: "analyzed",
type: "integer"
},
insertDate: {
index: "analyzed",
type: "integer"
}
}
}
}
}
}

Then I inserted few clips, some of them with multiple atribute such as :

  • subject: [
    • {
      • subjectId: 4
      • insertDate: 5
        }
    • {
      • subjectId: 3
      • insertDate: 6
        }
        ]

Problem is, when I try to search for clips that got subjectId = 3 and sort
result by insertDate what happens is ES would find
{subjectId=3,insertDate=6} but would sort results using FIRST attribute
(which is (subjectId=4,insertDate=5). So it finally finds data that I want
to find, but sorts them not with the attribute that MATCH to my query but
the first attribute. Is there any chance to fix this one?

Thats my query by the way

{"fields":["_parent","_source"],"query":{"bool":{"must":[{"range":{
"subjectId":{"gte":3,"lte":3}}}],"must_not":,"should":}},"from":0,
"size":50,"sort":[{"insertDate":{"reverse":false}}],"facets":{},"version":
true}

Thanks for checking out

--
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.
For more options, visit https://groups.google.com/groups/opt_out.