Cant map mysql timestamp in elasticsearch

I want to insert one of my mysql tables into elasticsearch for search, but I am having trouble displaying the timestamp from mysql in ES.

In mysql, my timestamp looks like "2015-01-01 15:30:34", I tried matching it as "timestamp" / "int" / "long", but nothing works. And, looking at the ES docs, it looks like the ES expects the timestamp to look like this: "2015-01-01T15: 30: 34"

with a "T" in it.

Can't display the usual mysql timestamp as "2015-01-01 15:30:34" in ES?

Second question: Since I have only one table in MySql that I want to look for, I only have this table in ES. And I do this: Each time a new row is inserted / updated / deleted in MySql, the same row is inserted / updated / deleted immediately after the ES. Is this the right way to do this? In order to update the index in real time.

I am using the Laravel package: https://github.com/adamfairholm/Elasticquent

Since this is the easiest I have found for someone new in ES.

0
source share
1 answer

A timestamp containing T is in ISO 8601 format . Since Laravel uses Carbon , you can use it to convert a string to ISO 8601 as follows:

 $myDateTime->toIso8601String(); 

As for your second question, you fit well. By synchronizing your MySQL inserts, updates, and deletes with ES, you will see that the ES index is updated in real time.

If re-checking real-time document documents of ES documents is poor for performance (usually if you have frequent inserts, updates, and deletions), you can configure cron to synchronize and reindex ES documents at a specific interval.

+1
source

Source: https://habr.com/ru/post/981969/


All Articles