Friday, 23 October 2015

Elasticsearch: String type

String is collection of one or more characters.
Example
PUT organization/_mapping/employee
{
 "employee":{
  "properties" : {
   "firstName" : {"type" : "string", "store" : true},
   "lastName" : {"type" : "string", "store" : true}
  }
 }
}

Response like below.

    {
       "acknowledged": true
    }

You can check the mappings for type employee using “_mapping”.
GET organization/_mapping/employee
Response like below.
{
   "organization": {
      "mappings": {
         "employee": {
            "properties": {
               "firstName": {
                  "type": "string",
                  "store": true
               },
               "lastName": {
                  "type": "string",
                  "store": true
               }
            }
         }
      }
   }
}

In addition to common attributes below are some additional attributes specific to data type string.

Attribute
Description
term_vector
Attribute specifies whether to calculate Lucene tern vectors or not. Possible values are no, yes, with_offsets, with_positions, with_positions_offsets. Defaults to no.
analyzer
Specifies name of the analyzer used for searching and indexing.
index_analyzer
The analyzer used to analyze the text contents when analyzed during indexing.
search_analyzer
The analyzer used to analyze the field when part of a query string. Can be updated on an existing field.
norms: {enabled: <value>}
Specifies whether norms are enabled for this field or not. Defaults to true for analyzed fields, and to false for not_analyzed fields.
norms: {loading: <value>}
It can take value "eager" or "lazy". "eager" means that the norms for this field are always loaded. "lazy" means that the norms will be loaded only when needed.
index_options
Possible values for this field are "docs", "freqs", and "positions".
"docs" : Only document numbers are indexed.
"freqs" : document numbers and term frequencies are indexed.
"positions" : document numbers, term frequencies, positions are indexed
Defaults to "positions" for analyzed fields, and to "docs" for not_analyzed fields.
ignore_above
The analyzer will ignore strings larger than this size. Useful for generic not_analyzed fields that should ignore long text.




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment