Doesn`t visible after refresh?


(Hubo3085632) #1

I encountered a problem that can not search a doc after refresh.
here is my operation:
1 client.prepareIndex(idx, idx, id).setSource(doc).execute();
2 client.admin().indices()
.prepareRefresh(idx)
.get();
3 client.prepareGet(idx, idx, id).get() (i get null);


(David Pilato) #2

Very strange as you don't even need to call refresh before calling GET by id.

I'd say that you have a bug somewhere in your code.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.


(Hubo3085632) #3

you means if i put a doc then i use 'GET' can find it immediately? 'GET' doesn`t like 'Search' need open segment?


(David Pilato) #4

Yes.


(Hubo3085632) #5

i have resolved this, just replace "execute()" with "get()" ,like this "client.prepareIndex(idx, idx, id).setSource(doc).get()"


(David Pilato) #6

Argh. I missed it in your first post. Indeed call execute().actionGet() or better just call get().


(system) closed #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.