What's the correct way to make a raw array field?


(bryan rasmussen) #1

Hi
I want to add a new mapping for tags that needs to be both analyzed and available raw, as per https://www.elastic.co/guide/en/elasticsearch/reference/current/_multi_fields.html however I also want tags to be an array (of course, and to be searchable by the index name "tag") but of course the raw field is also an array and I have to give it an index name.

Is the following reasonable?

"thing" : {
        "properties" : {
            "tags" : {"type" : "string", 
                      "fields": {
                         "tags": {"type" : "string", "index_name" : "tag","index": "analyzed", "analyzer": "danish"},
                          "raw": {"type": "string", index: "not_analyzed",index_name:"rawtag"}
                      }
        
        }
    }
}

Should the index_name for the raw field just be tag, and I can query on tag.raw like with a normal raw field, or (because of the index_name settings) should I have a different index_name like rawtag. Will the query then have to be on rawtag.raw, rawtag or what?

I'm asking beforehand because this seems like the kind of thing that could easily bring hard to find bugs into the mapping, and I don't want to have to reindex.


(system) #2