# Source only available after a node restart

**URL:** <https://discuss.elastic.co/t/source-only-available-after-a-node-restart/4834>\
**Category:** Elasticsearch\
**Created:** [July 12, 2011, 12:45am UTC](https://discuss.elastic.co/t/source-only-available-after-a-node-restart/4834 "2011-07-12T00:45:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Ward](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucas_ward/32/3177_2.png) [@Lucas\_Ward](https://discuss.elastic.co/u/Lucas_Ward)\
**Post date:** [July 12, 2011, 12:45am UTC](https://discuss.elastic.co/t/source-only-available-after-a-node-restart/4834/1 "2011-07-12T00:45:30Z")

</div>

All,

I am indexing data with the following mapping:

```
    {
        "typeName" : {
            "properties" : {
                "fullName" : {
                    "type" : "multi_field",
                    "fields":{
                         "fullName" : {"type" : "string",

```

"index" : "analyzed"},  
"untouched" : {"type" : "string",  
"index" : "not\_analyzed"}  
}  
}  
}  
}  
}

And indexing it by doing the following (in groovy):

```
public void simpleIndex(indexId, items){
    if(items.size() > 0){
        BulkRequestBuilder bulkRequestBuilder =

```

elasticSearchClient.prepareBulk()  
items.each { item -\>  
IndexRequestBuilder indexRequestBuilder =  
elasticSearchClient.prepareIndex(indexId, "typeName")  
indexRequestBuilder.setId(item.id.toString())  
indexRequestBuilder.setSource("fullName",  
item.getFullName())  
bulkRequestBuilder.add(indexRequestBuilder)  
}  
BulkResponse response =  
bulkRequestBuilder.execute().actionGet()  
if (response.hasFailures()) {  
log.error("Error indexing: $  
{response.buildFailureMessage()}")  
}  
}  
}

This isn't the only type that's in the index. Although, there are  
significantly less numbers of this type in the index than the other.  
To keep this issue simple, the following code snippet will not pass:

GetResponse getResponse = client.prepareGet(indexName, "typeName",  
"1").execute().actionGet()  
assert getResponse.exists()  
assert getResponse.id == "1"  
assert getResponse.fields.size() \> 0

It won't pass because fields is empty. However, the id is there and is  
correct. The same issue will happen when performing a search as well.  
I will get hits back, but no fields. So far, the only thing that fixes  
this is restarting the node. When the node comes back up, the fields  
will be there. I have tried a refresh, flush, and cache clear, all  
with no affect. The issue is the same when using both node and  
transport. I have also tried ditching the mapping for fear that the  
multi-field type was causing issues (even though it works elsewhere  
just fine) with no luck. Am I missing something?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 12, 2011, 12:47am UTC](https://discuss.elastic.co/t/source-only-available-after-a-node-restart/4834/2 "2011-07-12T00:47:48Z")

</div>

You will only get back fields if you explicitly specify them as stored _and_ ask for them in the Get request. Do you get the \_source back? GetResponse#source...

On Tuesday, July 12, 2011 at 3:45 AM, Lucas wrote:

> All,
> 
> I am indexing data with the following mapping:
> 
> {  
> "typeName" : {  
> "properties" : {  
> "fullName" : {  
> "type" : "multi\_field",  
> "fields":{  
> "fullName" : {"type" : "string",  
> "index" : "analyzed"},  
> "untouched" : {"type" : "string",  
> "index" : "not\_analyzed"}  
> }  
> }  
> }  
> }  
> }
> 
> And indexing it by doing the following (in groovy):
> 
> public void simpleIndex(indexId, items){  
> if(items.size() \> 0){  
> BulkRequestBuilder bulkRequestBuilder =  
> elasticSearchClient.prepareBulk()  
> items.each { item -\>  
> IndexRequestBuilder indexRequestBuilder =  
> elasticSearchClient.prepareIndex(indexId, "typeName")  
> indexRequestBuilder.setId(item.id.toString())  
> indexRequestBuilder.setSource("fullName",  
> item.getFullName())  
> bulkRequestBuilder.add(indexRequestBuilder)  
> }  
> BulkResponse response =  
> bulkRequestBuilder.execute().actionGet()  
> if (response.hasFailures()) {  
> log.error("Error indexing: $  
> {response.buildFailureMessage()}")  
> }  
> }  
> }
> 
> This isn't the only type that's in the index. Although, there are  
> significantly less numbers of this type in the index than the other.  
> To keep this issue simple, the following code snippet will not pass:
> 
> GetResponse getResponse = client.prepareGet(indexName, "typeName",  
> "1").execute().actionGet()  
> assert getResponse.exists()  
> assert getResponse.id == "1"  
> assert getResponse.fields.size() \> 0
> 
> It won't pass because fields is empty. However, the id is there and is  
> correct. The same issue will happen when performing a search as well.  
> I will get hits back, but no fields. So far, the only thing that fixes  
> this is restarting the node. When the node comes back up, the fields  
> will be there. I have tried a refresh, flush, and cache clear, all  
> with no affect. The issue is the same when using both node and  
> transport. I have also tried ditching the mapping for fear that the  
> multi-field type was causing issues (even though it works elsewhere  
> just fine) with no luck. Am I missing something?
> 
> Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Lucas\_Ward](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucas_ward/32/3177_2.png) [@Lucas\_Ward](https://discuss.elastic.co/u/Lucas_Ward)\
**Post date:** [July 12, 2011, 1:05am UTC](https://discuss.elastic.co/t/source-only-available-after-a-node-restart/4834/3 "2011-07-12T01:05:38Z")

</div>

Shay,

I do request the fields back in search, but was using a GetRequest as  
easier to express example. There is no \_source that comes back in the  
get. However, when I add the field as you suggest it does work.  
However, the search still has an issue despite expressing the field.  
However, I think I found the issue, which is something else I've  
noticed. Essentially, I have about 4 types in my index. One of those  
types has a property named, let's say 'widget'. Then I also have a  
type which has the name 'widget' in the index. Even though my search  
is restricting types, I will have to prepend the fieldname with the  
type name. For example, setField('widget.fullName') It's not really an  
issue, but just not something that's documented. I also don't  
understand why restarting the node removed the need to do it (but only  
in one case, which was strange). I would imagine it's an edge case  
though, and field names with the same name as a type in the index  
doesn't come up for a lot of people.

Lucas

On Jul 11, 7:47 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> You will only get back fields if you explicitly specify them as stored _and_ ask for them in the Get request. Do you get the \_source back? GetResponse#source...
> 
> On Tuesday, July 12, 2011 at 3:45 AM, Lucas wrote:
> 
> > All,
> 
> > I am indexing data with the following mapping:
> 
> > {  
> > "typeName" : {  
> > "properties" : {  
> > "fullName" : {  
> > "type" : "multi\_field",  
> > "fields":{  
> > "fullName" : {"type" : "string",  
> > "index" : "analyzed"},  
> > "untouched" : {"type" : "string",  
> > "index" : "not\_analyzed"}  
> > }  
> > }  
> > }  
> > }  
> > }
> 
> > And indexing it by doing the following (in groovy):
> 
> > public void simpleIndex(indexId, items){  
> > if(items.size() \> 0){  
> > BulkRequestBuilder bulkRequestBuilder =  
> > elasticSearchClient.prepareBulk()  
> > items.each { item -\>  
> > IndexRequestBuilder indexRequestBuilder =  
> > elasticSearchClient.prepareIndex(indexId, "typeName")  
> > indexRequestBuilder.setId(item.id.toString())  
> > indexRequestBuilder.setSource("fullName",  
> > item.getFullName())  
> > bulkRequestBuilder.add(indexRequestBuilder)  
> > }  
> > BulkResponse response =  
> > bulkRequestBuilder.execute().actionGet()  
> > if (response.hasFailures()) {  
> > log.error("Error indexing: $  
> > {response.buildFailureMessage()}")  
> > }  
> > }  
> > }
> 
> > This isn't the only type that's in the index. Although, there are  
> > significantly less numbers of this type in the index than the other.  
> > To keep this issue simple, the following code snippet will not pass:
> 
> > GetResponse getResponse = client.prepareGet(indexName, "typeName",  
> > "1").execute().actionGet()  
> > assert getResponse.exists()  
> > assert getResponse.id == "1"  
> > assert getResponse.fields.size() \> 0
> 
> > It won't pass because fields is empty. However, the id is there and is  
> > correct. The same issue will happen when performing a search as well.  
> > I will get hits back, but no fields. So far, the only thing that fixes  
> > this is restarting the node. When the node comes back up, the fields  
> > will be there. I have tried a refresh, flush, and cache clear, all  
> > with no affect. The issue is the same when using both node and  
> > transport. I have also tried ditching the mapping for fear that the  
> > multi-field type was causing issues (even though it works elsewhere  
> > just fine) with no luck. Am I missing something?
> 
> > Thanks in advance.

---

<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, 4:00am UTC](https://discuss.elastic.co/t/source-only-available-after-a-node-restart/4834/4 "2017-07-06T04:00:57Z")

</div>


