简体   繁体   中英

Elasticsearch NEST Indeces and Indexing

my following problem is, that I have a List of Items and want to index those with elasticsearch. I have a running elasticsearch instance, and this instance has an index called " default ".

So I'm running following code:

var items = GetAListOfItem();
var response = Client.IndexMany(items);

I also tried it with Client.IndexManyAsync(items) . But that didn't do anything.

Only 1 Item of this List gets indexed. Nothing more. I think its the last item, which got indexed.

I thought it could be a thing with IEnumerable and multiple enumerations, but i parsed it as a List<Item> .

Another Question would be about the best practice with Elasticsearch. Is it common to use a Index per Model. So if I'm gathering data from for example Exchange and another system, I would do 2 indeces?

  1. ExchangeIndex
  2. OtherSystemIndex

Thank you for your help.

Update: I saw that my Client.Index does all those calls succesful, but all those objects got the same ID from NEST. Normally she had to increment by herself, isnt it?

Update 2: I fixed the Indexing Problem. I had setup an empty ID-Field.

But still have the question mit best practive about Elasticsearch.

If you are uploading all the data with the same id, it will not increment the id, that will update the record with that id and you will have only one record, so you can upload the data without an id or give wherever unique id to identified the records. The other common problem is that your records have not the same mapping that you give for the index.

About the other question, in the indexes, you store the information that is relevant for you, even if that have content from many models, the only thing that you have to avoid is mix information, if you have an index about server logs dont mix it with user activities for example.

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