After Indexing waiting for green signal for search

Hi,

i am creating a test application with es. I am creating index on the fly
then adding documents in it. Then searching it.
While searching it is not able to give me any data. But when I wait for
green signal it searches for the key work and works .
Waiting for green signal is taking a lot of time. i want to avoid the time
taken for the index to be green. Am I missing something ?

        Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", 

"es1").put("client.transport.sniff", true).build();

        Client client = new TransportClient(settings).addTransportAddress(new 

InetSocketTransportAddress("localhost", 9300));

{"mappings":{"properties":{"attr1":{"type":"string","index":"analyzed","store":"yes"},"attr2":{"type":"string","index":"analyzed","store":"yes"},"attr3":{"type":"string","index":"analyzed","store":"yes"},"attr1":{"type":"string","index":"analyzed","store":"yes"}}}}

            IndexResponse response = 

client.prepareIndex(entity.getNamespace(),entity.getNamespace(),entity.getId())
.setConsistencyLevel(WriteConsistencyLevel.QUORUM).setSource(new
Gson().toJson(entityValue)).execute().actionGet();

// indexing is working file as I can see in cluster health the no of doc is
1

client.admin().cluster().prepareHealth("match").setWaitForGreenStatus().execute().actionGet();
*

SearchRequestBuilder searchRequestBuilder =
clientMap.get("match").prepareSearch("match").setTypes("match")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setFrom(0).setSize(60).setExplain(true).setQuery(QueryBuilders.fieldQuery("attr1",
"LEE"));

    SearchResponse matchResponse = searchRequestBuilder.execute()

.actionGet();

Thanks for Help

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You can try forcing a refresh on the index -

On Thursday, April 25, 2013 1:07:27 PM UTC+3, Arjit Gupta wrote:

Hi,

i am creating a test application with es. I am creating index on the fly
then adding documents in it. Then searching it.
While searching it is not able to give me any data. But when I wait for
green signal it searches for the key work and works .
Waiting for green signal is taking a lot of time. i want to avoid the time
taken for the index to be green. Am I missing something ?

        Settings settings = ImmutableSettings.settingsBuilder().put("

cluster.name", "es1").put("client.transport.sniff", true).build();

        Client client = new TransportClient(settings).addTransportAddress(new 

InetSocketTransportAddress("localhost", 9300));

{"mappings":{"properties":{"attr1":{"type":"string","index":"analyzed","store":"yes"},"attr2":{"type":"string","index":"analyzed","store":"yes"},"attr3":{"type":"string","index":"analyzed","store":"yes"},"attr1":{"type":"string","index":"analyzed","store":"yes"}}}}

            IndexResponse response = 

client.prepareIndex(entity.getNamespace(),entity.getNamespace(),entity.getId())
.setConsistencyLevel(WriteConsistencyLevel.QUORUM).setSource(new
Gson().toJson(entityValue)).execute().actionGet();

// indexing is working file as I can see in cluster health the no of doc
is 1

client.admin().cluster().prepareHealth("match").setWaitForGreenStatus().execute().actionGet();
*

SearchRequestBuilder searchRequestBuilder =
clientMap.get("match").prepareSearch("match").setTypes("match")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setFrom(0).setSize(60).setExplain(true).setQuery(QueryBuilders.fieldQuery("attr1",
"LEE"));

    SearchResponse matchResponse = searchRequestBuilder.execute()

.actionGet();

Thanks for Help

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.