Well, after a long hair-stretching weekend, I seem to have hit a bug or, at
least, unexpected behavior
I've tried all possible combinations, and I think something's not working
as it should.
first what seemed to be more logical:
{
"type1": {
"_boost": {"name": "df_boost", "null_value": 1.0},
"properties": {
"df_boost": {"type": "float", "index": "not_analyzed"}
}
}
}
I produced the following mapping
"type1": {
"_boost": {
"name": "df_boost",
"null_value": 1
},
"properties": {
"extra_field": {
"type": "double"
}
}
}
}
but after inserting some doc with a "df_boost" value, trying make a sorted
query:
{
"query": { "match_all": {}},
"sort": ["df_boost"]
}
sort wasn't working
{
"took": 8,
"hits": {
"total": 1,
"max_score": null,
"hits": [
{
"_index": "tito",
"_type": "type1",
"_id": "Hbcqp5yqQ5GL1YAcXcHdXw",
"_score": null,
"_source": {
"field": "value",
"df_boost": 34
},
"sort": [
"Infinity"
]
}
]
}
}
(check the "sort": ["Infinity"])
then I tried putting "index": "analyzed" in the root level definition.
{
"mappings":{
"type1":{
"_boost": {"name": "df_boost", "null_value": 1.0, "index":
"not_analyzed"},
"properties": {
"extra_field": {"type": "double"}
}
}
}
}
but an exception is raised then:
[2014-02-24 09:32:03,365][WARN ][indices.cluster ] [Master Khan] [
tito] failed to add mapping [type1], source [{"type1":{"_boost":{"name":
"df_boost","null_value":1.0,"index":true},"properties":{"extra_field":{
"type":"double"}}}}]
org.elasticsearch.index.mapper.MapperParsingException: Wrong value forindex
[true] for field [df_boost]
at org.elasticsearch.index.mapper.core.TypeParsers.parseIndex(
TypeParsers.java:194)
at org.elasticsearch.index.mapper.core.TypeParsers.parseField(
TypeParsers.java:76)
at org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField(
TypeParsers.java:51)
at org.elasticsearch.index.mapper.internal.
BoostFieldMapper$TypeParser.parse(BoostFieldMapper.java:99)
at org.elasticsearch.index.mapper.DocumentMapperParser.parse(
DocumentMapperParser.java:235)
at org.elasticsearch.index.mapper.DocumentMapperParser.
parseCompressed(DocumentMapperParser.java:183)
at org.elasticsearch.index.mapper.MapperService.parse(MapperService.
java:322)
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.
java:200)
at org.elasticsearch.indices.cluster.IndicesClusterStateService.
processMapping(IndicesClusterStateService.java:405)
at org.elasticsearch.indices.cluster.IndicesClusterStateService.
applyMappings(IndicesClusterStateService.java:360)
at org.elasticsearch.indices.cluster.IndicesClusterStateService.
clusterChanged(IndicesClusterStateService.java:179)
at org.elasticsearch.cluster.service.
InternalClusterService$UpdateTask.run(InternalClusterService.java:416)
at org.elasticsearch.common.util.concurrent.
PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(
PrioritizedEsThreadPoolExecutor.java:135)
at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
it looks like "index":"not_analyzed" is not something that should be
defined in "_boost".
anyway, now the mapping is:
"type1": {
"_boost": {
"name": "df_boost",
"null_value": 1,
"index": true
},
"properties": {
"extra_field": {
"type": "double"
}
}
}
see how a new "index": true has appeared, in spite of the previous
exception being raised.
and now, sorted query work!
{
"query": { "match_all": {}},
"sort": ["df_boost"]
}
provdes:
{
"took": 8,
"hits": {
"total": 1,
"max_score": null,
"hits": [
{
"_index": "tito",
"_type": "type1",
"_id": "6r-8C64RSNuPQ1vGPENK6g",
"_score": null,
"_source": {
"field": "value",
"df_boost": 34
},
"sort": [
34
]
}
]
}
}
Notice how no there is a value for the "sort" field.
But, because this exception raising, my python client (pyes) and probably
others, doesn't seem to fulfill the mapping creation, so If I want this
feature, I have to use the API "on straight" and also let the system throw
an exception for no good reason.
;-(
On Wednesday, February 19, 2014 4:36:25 PM UTC-5, JoeZ99 wrote:
according to martijin's remarks on
Redirecting to Google Groups
and also this issue
Allow _boost field to be indexed and stored in mapping · Issue #3752 · elastic/elasticsearch · GitHub ,
search results should be sortable by _boost field.
my particular setup:
{
"product": {
"properties": {
"_boost": {
"type": "float",
"null_value": 1.0,
"index": "not_analyzed"
}
}
}
when using a match_all query, I can sort for any numeric field, but the
"_boost", that does not work. I'm using 0.90.10
Also, I don't know if this is related, but when I try to get the mapping
via localhost:9200/index_name/_mapping , the _boost field doesn't show up.
I guess it's because of its special nature.
--
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/afa0490e-d668-4912-8ad0-145e54354a4d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.