# After Indexing waiting for green signal for search

**URL:** <https://discuss.elastic.co/t/after-indexing-waiting-for-green-signal-for-search/11692>\
**Category:** Elasticsearch\
**Created:** [April 25, 2013, 10:07am UTC](https://discuss.elastic.co/t/after-indexing-waiting-for-green-signal-for-search/11692 "2013-04-25T10:07:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arjit\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@Arjit\_Gupta](https://discuss.elastic.co/u/Arjit_Gupta)\
**Post date:** [April 25, 2013, 10:07am UTC](https://discuss.elastic.co/t/after-indexing-waiting-for-green-signal-for-search/11692/1 "2013-04-25T10:07:27Z")

</div>

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Yehuda\_Zargarov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehuda_zargarov/32/2164_2.png) [@Yehuda\_Zargarov](https://discuss.elastic.co/u/Yehuda_Zargarov)\
**Post date:** [April 25, 2013, 12:42pm UTC](https://discuss.elastic.co/t/after-indexing-waiting-for-green-signal-for-search/11692/2 "2013-04-25T12:42:11Z")

</div>

You can try forcing a refresh on the index -

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:39am UTC](https://discuss.elastic.co/t/after-indexing-waiting-for-green-signal-for-search/11692/3 "2017-07-06T02:39:39Z")

</div>

Closed on July 6, 2017, 2:39am UTC


