3

I am writing some tests to Search documents in ElasticSearch but I am receiving an IndexMissingException [indexed_store_detail] missing.I create a Node inside my tests.At the start of the test I insert the document and when I make the following call I get the exception.

SearchResponse response = getClient()
            .prepareSearch(getIndexNameV2(), getIndexTypeV2())
            .setQuery(QueryBuilders.idsQuery().addIds("1"))
            .execute().actionGet();

This is weird because the GetResponse works fine with the same and literally the same code.What could be wrong ?

GetResponse response = getClient().prepareGet(getIndexNameV2(), getIndexTypeV2(),"1")
            .execute().actionGet();

org.elasticsearch.indices.IndexMissingException: [indexed_store_detail] missing
at org.elasticsearch.cluster.metadata.MetaData.convertFromWildcards(MetaData.java:648)
at org.elasticsearch.cluster.metadata.MetaData.concreteIndices(MetaData.java:559)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.<init>(TransportSearchTypeAction.java:112)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.<init>(TransportSearchQueryThenFetchAction.java:70)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.<init>(TransportSearchQueryThenFetchAction.java:61)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction.doExecute(TransportSearchQueryThenFetchAction.java:58)
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction.doExecute(TransportSearchQueryThenFetchAction.java:48)
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)
at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:108)
at org.elasticsearch.action.search.TransportSearchAction.doExecute(TransportSearchAction.java:43)
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)
at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:92)
at org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:214)
at org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:841)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:62)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:57)
at com.paypal.demandgen.places.search.server.search.TestElasticSearchResponseParserV3toV1.parsePassesForSearchResponse(TestElasticSearchResponseParserV3toV1.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
5
  • Does it work after the first run? Searching is not real time in Elasticsearch. It's near real time. If you were typing it all in on the command line (e.g., using curl), then it would probably look like it was real time. However, the time between executing commands will be much faster, so I expect that you either mistyped the index name (hence the 404-like exception), or you are searching for the response too fast. Honestly though, I suspect the former more than the ladder because the index's existence will appear before the document is actually searchable, but you can still be faster. Commented Mar 28, 2014 at 17:49
  • No it does not work after the first run.It fails each time a prepareSearch Request but passes everytime for the prepareGet request Commented Mar 28, 2014 at 18:34
  • Since these are being performed by JUnit, it is also possible that these queries are being done in parallel (or very close to it), which would probably make this happen. Make sure that the indexing has actually happened, probably in a @BeforeClass and possibly with a forced delay. Can we see the indexing code (and how it interacts with the search code)? Commented Mar 28, 2014 at 18:37
  • There is only one test case.When I said the GetResponse works and SearchResponse does not I comment out the one not being used Commented Mar 28, 2014 at 19:32
  • GetResponses are not the same as searching, as they just perform a lookup to fetch the record (assuming it exists), which should exist immediately after indexing. SearchResponses require that the document has been analyzed before it will return them. Commented Mar 28, 2014 at 19:40

1 Answer 1

1

I found what the mistake was .It should have been called in the following fashion.It was a learning for me

getClient() .prepareSearch(getIndexNameV2()).getType(getIndexTypeV2())  
Sign up to request clarification or add additional context in comments.

1 Comment

Ah ha! Good catch, I suppose indexed_store_detail is the type rather than the index. That is a slightly annoying difference between the search and get APIs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.