简体   繁体   中英

ElasticSearch Mapping Non Searchable Field

Im new to elastic search.

In my users type in profiles index i have fields

properties : {
    name : {type : string},
    picture : {
                  url_small : {}
                  url_big : {}   
         } 
}

In this index picture is just for storing/getting data and will never be used in doing any query but only will be retrieved with matched hits.

So how to create the mapping of picture ? What type , analyzer ,fields should i use ?

Concepts:

You are dealing with two things here:

  1. How the data will be stored
  2. How the data will be indexed

To define how the data will be stored, you use type .

To define how the data will be indexed (directly, after being analyzed, or, in your case, not indexed), you use index .

And if you want to define how the data is analyzed for the indexing, you have to use analyzer .

In your case:

You want to store string, but not to index them, so you use:

{
    type: string,
    index: no
}

Which gives you:

properties : {
    name : {"type": "string"},
    picture : {
        url_small : {
            "type": "string",
            "index": "no"
        },
        url_big : {
            "type": "string",
            "index": "no"
        }   
    } 
}

More info on the index field here:

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-index.html

Hope it's clear

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM