简体   繁体   中英

Can I use elasticsearch to store only unstructured data?

Not much to ask, but new to Elasticsearch. Most of the material I come across, people first create an client and then create an index by providing a mapping.

Can I do it without any mapping? So for example, if I have a Twitter index.

I have 3 different structs, one for tweet, one for user and one for private messages. Can I just store all documents (which might belong to any of these 3 types) under the same Index?

NOTE: This is a hypothetical example to help me understand. I don't want any code.

You can do it. What will happen if you do so? ES performs default type conversion on field based on data.

If you have a string data, it will be stored as text . In this case default analyzer will be applied on the data. If you want to know more, default analyzer

  1. Your data may have there are amazing creatures . But when you search for doc contains amaze you may expect this data also part of it. You ll not get it.
  2. Phonetic handling
  3. Numbers handling
  4. IP handling
  5. Url handling
  6. Email handling

Many more cases cannot be handled properly. If your use case meets the default mapping, then you can go ahead and use.

Later to update mapping, you need to reindex the data.

First of all, you can just add a document and ES will take care of creating index and mapping for you. But this is only possible if your cluster-level setting

 "action.auto_create_index": "false"

Is set to true, By default, it is true unless someone explicitly updates it to false using

PUT _cluster/settings
{
  "persistent": {
    "action.auto_create_index": "false"
  }
}

Also, there can be few issues like having generic datatypes even if you are planning to have some specific data types.

I had a detailed article on how these settings and automatic mapping works and also pros and cons of it

https://xyzcoder.github.io/2020/08/03/elastic-search-mapping-and-index-creation.html

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