Raw vs full text search


(Craig Ching) #1

I need to have a field be searchable using both full text and exact match searches. I've been creating a separate field doing something like "name" and "name_raw", but reading the documentation I see that collapsed fields look like a nice way to resolve this, e.g.:

{
    "properties": {
        "user": {
            "properties": {
                "name": { 
                    "type": "string",
                    "fields": {
                        "raw": { 
                            "type":  "string",
                            "index": "not_analyzed"
                        }
                    }
                }
            }
        }
    }
}

Would that be considered a best practice? Is there any reason not to do this?


(Colin Goodheart-Smithe) #2

Yep, the above (multi-fields) would be the preferred way to do this :slight_smile:


(Craig Ching) #3

Awesome! Thanks Colin!


(system) #4