user9610034
user9610034

Reputation:

Fields that need not be searchable in ElasticSearch

I am using ElasticSearch v6 to search my product catalog.

My product has a number fields, such as title, description, price, etc... one of the fields is: photo_path, which would contain the location of product photo on disk.

photo_path does need to be searched, but need to be retrieved.

Question: Is there a way to mark this field as not searchable/not indexed? And is this a good idea, for example will I save storage/process time, by marking this field not searchable.

I have seen this answer and read, _source and _all, but since _all is deprecated in version 6, I am confused what to do.

Upvotes: 0

Views: 1181

Answers (1)

Derek J.
Derek J.

Reputation: 126

If you want some field are not indexed are not queryable, setting property"index": false, and if you only want "photo_path" field as the search result, includes this field on source only (save disk space and fetch less data from disk), show mappings like below:

{
"mappings": {
    "data": {
        "_source": {
            "includes": [
                "photo_path" // search result only contains this
            ]
        },
        "properties": {
            "photo_path": {
                "type": "keyword",
                "doc_values": false,  // Set docValues as false if you don't want to use this field to sort/aggregate
                "index": false   // Not index this field
            },
            "title": {
                "type": "..."
            }
        }
    }
}

}

Upvotes: 1

Related Questions