Can't order by _boost field, even when "index":"not_analyzed"


(José de Zárate) #1

according to martijin's remarks on
https://groups.google.com/forum/#!topic/elasticsearch/A5DSgvnTnC0
and also this issue
https://github.com/elasticsearch/elasticsearch/issues/3752 ,

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/e22fe979-1978-4e5d-8a7c-73a6dd238cdf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Ivan Brusic) #2

The boost field, like other special fields such as timestamp and id, is set
at the root level of a type, not as a property:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-boost-field.html

Perhaps I should have added this confusion as yet another reason why to
avoid the boost field:

--
Ivan

On Wed, Feb 19, 2014 at 1:36 PM, JoeZ99 jzarate@gmail.com wrote:

according to martijin's remarks on
https://groups.google.com/forum/#!topic/elasticsearch/A5DSgvnTnC0
and also this issue
https://github.com/elasticsearch/elasticsearch/issues/3752 ,

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/e22fe979-1978-4e5d-8a7c-73a6dd238cdf%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQA-Xm9bwsG54uMzduqXcV2_%2BCPWrcD5zJWHFJMnLAzPYA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(José de Zárate) #3

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
https://groups.google.com/forum/#!topic/elasticsearch/A5DSgvnTnC0
and also this issue
https://github.com/elasticsearch/elasticsearch/issues/3752 ,

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.


(Binh Ly) #4

Yup, this is a known bug. Since _boost is being deprecated and replaced by
function_score, this will likely not be fixed. For now if you want to sort
on a "boost" value, either remove the _boost from your mapping, or
introduce another field that you don't refer to from _boost.

--
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/026c733c-9077-434d-b92d-9d8dacbf9f50%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(José de Zárate) #5

Ok, .

Good to know, I wish I knew this a few days before :wink: I was really loosing
my mind on this!!

yet another reason for dropping indexing time defined boost, I guess. I
really wish there were any way of defining per-document boost at index
time.

txs!

On Monday, February 24, 2014 5:14:48 PM UTC-5, Binh Ly wrote:

Yup, this is a known bug. Since _boost is being deprecated and replaced by
function_score, this will likely not be fixed. For now if you want to sort
on a "boost" value, either remove the _boost from your mapping, or
introduce another field that you don't refer to from _boost.

--
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/b1bd446d-8fc9-4d58-84aa-f86f6d3a43e1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #6