How to Elasticsearch entities not created using AP

2019-06-14 04:26发布

问题:

Using Jhipster with Postgresql, I have created an entity "Customer". When I add data to this entity using the Angular UI or POST to the API, I can search this data using the search form on the UI.

However, when I insert data in the database directly, the data is not searchable even after application restart. The search would still work (only) on the data added through the UI.

I am new to elasticsearch and do not know if there is a missing step between inserting data on the backend and making it available to elasticsearch. Please help, if there is something I need to configure to let elasticsearch pick up data from the database during application startup.

My application-dev.yml excerpt for spring data elasticsearch:

    data:
    elasticsearch:
        cluster-name:
        cluster-nodes:
        properties:
            path:
              logs: target/elasticsearch/log
              data: target/elasticsearch/data

回答1:

Elasticsearch is essentially a datastore which is why JHipster saves to the search repositories at the same time as the regular JPA repositories. There is no built-in reindexing functionality for making changes to it outside of the API.

I have written a module that will generate a service for reindexing all entities.

https://github.com/geraldhumphries/generator-jhipster-elasticsearch-reindexer