Spring data in elasticsearch and elasticsearch REST API


I’m very new in elasticsearch, but it’s looks very nice and I like it

I have simple domain and spring elasticsearch repository

@Document(indexName = "user", type = "customer")

public class CustomerUser {
String id;
String username, name;

public interface CustomerUserRepository extends ElasticsearchRepository<CustomerUser, String> {}

What I’m expecting is to have some kind of data/API synchronization between spring-data-elasticsearch and elasticsearch REST API, so different apps can use both - my custom backend API and elasticsearch API

I’ve created few items using my custom REST API and spring-data repository:
http post :8001 name=Max1 username=daggerok1
http get :8001/users

“_embedded”: {
“userList”: [
“id”: “AV-DhBJaR-bqR3BWmtKy”,
“name”: “Max1”,
“username”: “daggerok1”

but I cannot query/access them using elasticsearch REST API by /user/customer/$ID

http -a elastic:changeme :9200/user/customer/AV-DhBJaR-bqR3BWmtKy

HTTP/1.1 404 Not Found

Can anybody point me what I’m doing wrong and how I should store spring-data items or configure my spring-boot app for accessing them later using elasticsearch REST API too? Just like so:

echo ‘{“username”:“daggerok”,“name”:“Max”}’|http -a elastic:changeme :9200/user/customer
HTTP/1.1 201 Created
Location: /user/customer/AV-DkFD1Y98z-Zp73zW8

“_id”: “AV-DkFD1Y98z-Zp73zW8”,
“_index”: “user”,
“_shards”: {
“failed”: 0,
“successful”: 1,
“total”: 2
“_type”: “customer”,
“_version”: 1,
“created”: true,
“result”: “created”

$ http -a elastic:changeme :9200/user/customer/AV-DkFD1Y98z-Zp73zW8
HTTP/1.1 200 OK

“_id”: “AV-DkFD1Y98z-Zp73zW8”,
“_index”: “user”,
“_source”: {
“name”: “Max”,
“username”: “daggerok”
“_type”: “customer”,
“_version”: 1,
“found”: true

I’ve also tried on application bootstrap explicitly create index and mapping, but it’s doesn’t helped: