Facets sort issue (date)


(aditya.kulkarni) #1

Hi,

Here is my sample Data along with mapping
{

"MainPostingID": "123345" // mapping: string
"date": "2011-09-01T17:10:42", // mapping : date
"sender_number": "324233393331333933333337333033", // mapping :
string, index: not_analyzed, as it can contain alphabates, +, 0-9
"msg_text": "%22Change+can%27t+be+given+to+you+everytime" // mapping :
string
}

Multiple such entries get generated for main posting. Now I run
following facet query with date sort.
Aim: create facets for Main posting by sender and get them sorted by
date.

e.g.
curl -XPOST 'http://127.0.0.1:9200/postings/message/_search' -d '
{
"size": 0,
"sort": [
{
"date": {
"order": "asc"
}
}
],
"query": {
"field": {
"MainPostingID": "123345"
}
},
"facets": {
"myFacet": {
"terms": {
"fields": [
"sender_number"
]
}
}
}
}'

Issue for which I need help!
Facets are coming with no issues. Problem is with sorting as it sorts
facets by sender_number and not by date.

Thanks in advance!

Best Regards,
Aditya


(Jürgen kartnaller) #2

You can not sort a facet with the query sort.

The facet gets the unsorted and unfiltered query result.

See
http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html
on
how to sort the result of the terms facet.

Jürgen

On Fri, Sep 2, 2011 at 5:40 PM, Aditya aditya.kulkarni@gmail.com wrote:

Hi,

Here is my sample Data along with mapping
{

"MainPostingID": "123345" // mapping: string
"date": "2011-09-01T17:10:42", // mapping : date
"sender_number": "324233393331333933333337333033", // mapping :
string, index: not_analyzed, as it can contain alphabates, +, 0-9
"msg_text": "%22Change+can%27t+be+given+to+you+everytime" // mapping :
string
}

Multiple such entries get generated for main posting. Now I run
following facet query with date sort.
Aim: create facets for Main posting by sender and get them sorted by
date.

e.g.
curl -XPOST 'http://127.0.0.1:9200/postings/message/_search' -d '
{
"size": 0,
"sort": [
{
"date": {
"order": "asc"
}
}
],
"query": {
"field": {
"MainPostingID": "123345"
}
},
"facets": {
"myFacet": {
"terms": {
"fields": [
"sender_number"
]
}
}
}
}'

Issue for which I need help!
Facets are coming with no issues. Problem is with sorting as it sorts
facets by sender_number and not by date.

Thanks in advance!

Best Regards,
Aditya

--
http://www.sfgdornbirn.at
http://www.mcb-bregenz.at


(system) #3