Searching and Sorting on ElasticSearch

Hi im implementing ES as my SE and i have some questions about what im
doing wrong.

The main idea its to have a set of posts that i want to search over some
text fields and sort the results by relevance and then by creation date
(one of the fields). Im using node js with the default es library.

Here its my mapping:

{
"version": 1,
"conf": {
"settings": {
"analysis": {
"filter": {
"snowball": {
"type": "snowball",
"language": "English"
},
"english_stemmer": {
"type": "stemmer",
"language": "english"
},
"english_possessive_stemmer": {
"type": "stemmer",
"language": "possessive_english"
},
"stopwords": {
"type": "stop",
"stopwords": ["english"]
},
"worddelimiter": {
"type": "word_delimiter"
}
},
"tokenizer": {
"nGram": {
"type": "nGram",
"min_gram": 3,
"max_gram": 20
}
},
"analyzer": {
"custom_analyzer": {
"type": "custom",
"tokenizer": "nGram",
"filter": [
"stopwords",
"asciifolding",
"lowercase",
"snowball",
"english_stemmer",
"english_possessive_stemmer",
"worddelimiter"
]
},
"custom_search_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"stopwords",
"asciifolding",
"lowercase",
"snowball",
"english_stemmer",
"english_possessive_stemmer",
"worddelimiter"
]
}
}
}
},
"mappings": {
"posts": {
"model": "Post",
"properties": {
"id": {
"type": "long"
},
"title": {
"type": "string",
"analyzer": "custom_analyzer",
"boost": 5
},
"description": {
"type": "string",
"analyzer": "custom_analyzer",
"boost": 4
},
"categories": {
"type": "string",
"analyzer": "custom_analyzer"
},
"seller": {
"type": "object",
"properties": {
"id": {
"type": "long"
},
"username": {
"type": "string",
"analyzer": "custom_analyzer",
"boost": 1
},
"firstName": {
"type": "string",
"analyzer": "custom_analyzer",
"boost": 3
},
"lastName": {
"type": "string",
"analyzer": "custom_analyzer",
"boost": 2
}
}
},
"marketPrice": {
"type": "float"
},
"currentPrice": {
"type": "float"
},
"discount": {
"type": "float"
},
"commentsCount": {
"type": "integer",
"index": "not_analyzed"
},
"likesCount": {
"type": "integer",
"index": "not_analyzed"
},
"created": {
"type": "date",
"index": "not_analyzed"
},
"modified": {
"type": "date",
"index": "not_analyzed"
}
}
}
}
}}

I have indexed 10 documents:

| id | title | description | market_price | item_condition | iso | comment_count | created |
| 1 | Post 1 | Post 1 Description | 1 | 1 | 1 | 1 | 2014/01/01 |
| 2 | Post 2 | Post 2 Description | 1 | 1 | 1 | 1 | 2014/01/02 |
| 3 | Post 3 | Post 3 Description | 1 | 1 | 1 | 1 | 2014/01/03 |
| 4 | Post 4 | Post 4 Description | 1 | 1 | 1 | 1 | 2014/01/04 |
| 5 | Post 5 | Post 5 Description | 1 | 1 | 1 | 1 | 2014/01/05 |
| 6 | Post 6 | Post 6 Description | 1 | 1 | 1 | 1 | 2014/01/06 |
| 7 | Post 7 | Post 7 Description | 1 | 1 | 1 | 1 | 2014/01/07 |
| 8 | Post 8 | Post 8 Description | 1 | 1 | 1 | 1 | 2014/01/08 |
| 9 | Post 9 | Post 9 Description | 1 | 1 | 1 | 1 | 2014/01/09 |
| 10 | Post 10 | Post 10 Description | 1 | 1 | 1 | 1 | 2014/01/010 |

Assume that the seller info its there two, i dont add it here because the
post will be extensive.

My query its:

GET /clamour_develop/_search{
"query": {
"multi_match": {
"query": "post 1",
"fields": [ "title", "description", "seller.first_name", "seller.last_name", "seller.username" ],
"analyzer": "custom_search_analyzer"
}
},
"sort": [
{
"_score":{
"order": "desc"
}
},{
"created": {
"order": "desc"
}
}
]
}

I expect to receive the documents in the order

Post 1
Post 10
Post 9
Post 8
Post 7
Post 6
Post 5
Post 4
Post 3
Post 2

But i get

Post 1
Post 10
Post 8
Post 3
Post 9
Post 7
Post 6
Post 4
Post 2
Post 5

What im doing wrong?

Thanks

--
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/527a46e0-985a-45dd-9a2f-57108c738a97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.