1
votes

I am trying to re-index my documents in order for them to be sortable which requires making the sortable fields Multi-field properties with a "raw" version of the string which does not get analyzed.

I am following this article, but I am still getting errors when searching my documents with a sorting query.

I have a question then regarding the re-indexing of the data... if I re-index the doucments into this new index, then do I need to have some extra logic to set the analyzed version and the non_analyzed or "raw" version of the string as well? Or does elastic search automatically fill that one? Here is what my field looks like:

{
    "entityName": {
        "type":"string",
        "fields": {
            "raw": {
                "type":"string",
                "index":"not_analyzed"
            }
        }
    }
}

So when I index a document with a _source like:

{
...
"entityName":"Ned Stark"
...
}

Will the mapping to both the analyzed field and the not_analyzed field complete or is there something else I have to do to tell the indexing to fill in the "raw" property as well?

1
It should index both. What happens in your case?Andrei Stefan
@AndreiStefan I will update it in a second.Matt Hintzke
@MattHintzke _source will not change as it holds the same value in both cases. The thig is how are they indexed. So mutlifields are not to create multiple fields, but to logical single field to be indexed multiple times in different way. For example, using multiple analyzers is not allowed, but you can use 2 multifields, each with different analyzer.Antoniossss

1 Answers

3
votes

No, you don't need to do anything else.

After reindexing your documents, you must tell which fields the query should use like in your given documentation article.

Raw subfield:

POST /_search
{
    "query": {
        "match": {
            "entityName.raw": "foo-bar"
        }
    }
}

or original analysed type:

POST /_search
{
    "query": {
        "match": {
            "entityName": "foo-bar"
        }
    }
}