Querystring search on array elements in Elastic Search

For that requirement to be achieved, you need to look at nested objects, not to query a flattened list of values but individual values from that nested object. For example: { “mappings”: { “people”: { “properties”: { “name”: { “type”: “string” }, “quotations”: { “type”: “nested”, “properties”: { “value”: { “type”: “string” } } } … Read more

How to update a field type in elasticsearch

You need to define a mapping using Put Mapping API. curl -XPUT ‘http://localhost:9200/twitter/_doc/_mapping’ -H ‘Content-Type: application/json’ -d ‘ { “_doc” : { “properties” : { “message” : {“type” : “text”, “store” : true} } } } ‘ A date can be defined as follow: curl -XPUT ‘http://localhost:9200/twitter/_doc/_mapping’ -H ‘Content-Type: application/json’ -d ‘ { “_doc” : … Read more

How to Do a Mapping of Array of Strings in Elasticsearch

In Elasticsearch, there is no dedicated array type. Any field can contain zero or more values by default, however, all values in the array must be of the same datatype. So you don’t have to specify anything specific in the mapping to store an array of values. For more information look at: https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html

How to update multiple documents that match a query in elasticsearch

You could use the update by query plugin in order to do just that. The idea is to select all document without a category and whose url matches a certain string and add the category you wish. curl -XPOST ‘localhost:9200/webproxylog/_update_by_query’ -H “Content-Type: application/json” -d ‘ { “query”: { “filtered”: { “filter”: { “bool”: { “must”: … Read more

Removing old indices in elasticsearch

Curator would be an ideal match here. You can find the link here – https://github.com/elastic/curator A command like below should work just fine – curator –host <IP> delete indices –older-than 30 –prefix “twitter-” –time-unit days –timestring ‘%Y-%m-%d’ You can keep in this in the CRON for removing the indices occasionally. You can find some examples … Read more