Sample data
To better explain the various concepts in this chapter, we will use the e-commerce site as an example. We will create an index with a list of products. This will be a very simple index called chapter6
with type called product
. The mapping for the product
type is shown here:
#Delete existing index if any DELETE chapter6 #Mapping PUT chapter6 { "settings": {}, "mappings": { "product": { "properties": { "product_name": { "type": "text", "analyzer": "english" }, "description" : { "type": "text", "analyzer": "english" } } } } }
For the product_name
and description
fields, the English analyzer will be used instead of the default standard analyzer. Let's index some product documents:
#Index Documents PUT chapter6/product/1 { "product_name": "Men's High Performance Fleece Jacket", "description": "Best Value. All season fleece jacket", "unit_price": 79.99, "reviews": 250, ...