Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow _boost field to be indexed and stored in mapping #3752

Closed
martijnvg opened this issue Sep 20, 2013 · 3 comments
Closed

Allow _boost field to be indexed and stored in mapping #3752

martijnvg opened this issue Sep 20, 2013 · 3 comments

Comments

@martijnvg
Copy link
Member

The idea of the _boost field is that it provides an index time boost for all fields a document has, because of this the _boost field isn't stored or indexed separately and only saved as part of the _source.

However the _boost field is also used to as just a sort field, but because it can't be indexed separately, this doesn't work. By allowing to make the _boost indexable separately, sorting by the _boost field does work. By default the _boost field remains not indexed and not stored.

This issue originates from PR #2913

@JoeZ99
Copy link

JoeZ99 commented Feb 19, 2014

has this feature been removed for 0.90.10? (I thought it might, since the _boost field is deprecated in 1.X). I have

{
    "_boost": {
        "type": "float",
        "index": "not_analyzed"
    }
}

in my mappings definition and, besides not getting any info on "_boost" field when I access _mapping entrypoint (which I guess is due to the _boost field being "special"), can't get ES to sort by it.
Just want to know if it's removed. otherwise, I'll post this at the users group like a good kid. ;-)

@javanna
Copy link
Member

javanna commented Feb 19, 2014

Hi @JoeZ99 , the document boost wasn't removed for now, just deprecated in the documentation.

@JoeZ99
Copy link

JoeZ99 commented Feb 24, 2014

there seems to be a bug or at least, unexpected behavior with this.
more info at: https://groups.google.com/d/msg/elasticsearch/RvZZQa3ZbTA/Ofw_bg2be2oJ

here's how to reproduce it

create an index with a _boost mapping

POST http://localhost:9200/tito
{
  "mappings":{
    "type1":{
      "_boost":  {"name": "df_boost", "null_value": 1.0, "index": "not_analyzed"},  
        "properties": {

          "extra_field": {"type": "double"}
        }
    }   
  }
}

an exception is raised in elasticsearch

[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 for index [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)

the exception is about the "index": "not_analyzed" attribute of the "_boost" element.

However, the mapping is done

GET http://localhost:9200/tito/_mapping
{
    "tito": {
        "type1": {
            "properties": {
                "df_boost": {
                    "type": "long"
                },
                "field": {
                    "type": "string"
                }
            }
        }
    }
}

and sorting by boost is possible!

GET http://localhost:9200/tito/_search 

{
    "query": {"match_all": {} },
    "sort": ['df_boost"]
}
{
    "took": 4,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 1,
        "max_score": null,
        "hits": [
            {
                "_index": "tito",
                "_type": "type1",
                "_id": "6r-8C64RSNuPQ1vGPENK6g",
                "_score": null,
                "_source": {
                    "field": "value",
                    "df_boost": 34
                },
                "sort": [
                    34
                ]
            }
        ]
    }
}

this works whe accessing the REST API , but when using the pyes python client, the mapping never gets to a good ending.

THe issue/bug is that it throws an exception for no good reason.

I'm using elasticasearch 0.9.10

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants