2

I have just updated a website, the update adds new fields to elasticsearch.

In my dev environment, it all works fine. but on the live site, the new fields are not being found.

Eg. I have added a new field with the value : 1

However, when adding a filtered query of

{"field":1}

It does not find any matching results.

When I look in the documents, I can see docs with the field set to 1

Would the reason for this be that the new field was added after the mappings was set? I am not all that familiar with elasticsearch, So I am not really sure where to start looking to fix it.

Any help would be appreciated.

Update:

querying from URL shows nothing either

_search/?pretty=true&size=50&q=field1:*

however there is another field that was added at the same time which I can search on. I can see field1 in the result set but it just wont allow me to search on it.

Only difference i see in the mapping is that the one that is working is set to type:long whereas the one not working is set as type:string

4
  • Please show the actual steps that you are using to reproduce this problem. There are too many moving parts to be able to give you an answer with just the information you provided above. Commented Feb 3, 2014 at 11:06
  • I have added a few more things I have tried. The field does show in the mapping, it does show in the result set, but will not allow me to search on it. Commented Feb 3, 2014 at 18:09
  • Can you add the entire mapping that is being used for this index and/or type to your question? Commented Feb 6, 2014 at 13:48
  • 1
    I repeat my request for more information. Please add (1) the full mapping (retrieved from Elasticsearch), (2) the actual doc (retrieved from Elasticsearch) and (3) the actual curl command that you are using to verify that this doesn't work. Commented Feb 6, 2014 at 15:21

2 Answers 2

1
+50

Is it a length issue on the ngram? what was your "min_gram" settings? When you check on your index settings like this:

GET <host>/<index_name>/_settings

Does it work when you filter for a two digit field? Are all the field values one digit?

Sign up to request clarification or add additional context in comments.

Comments

1

It's OK to add a field after the mapping was set. ElasticSearch will guess the mapping for you. (in fact, it's one of their selling features --- no need to define the mapping, just throw the data at it)

There are a few things that can go wrong:

  1. Verify that data is actually in the index. To do that, just navigate to the _search url with no parameters, you should see the field if it is indexed.

  2. Look at your mapping. Could it be that the field is explicitly set not to be indexed?

  3. Another possibility is that your query is wrong (but that is unlikely, since you're saying it works in the development environment)

2 Comments

Thanks for your help. I have tried to look at the _search and the record with the field set is there showing the correct value. The odd thing is, I have added multiple fields in. So using the url method, I have done a search on the other field added (?q=field2:*) and it finds the result but if I try (?q=field1:*) it comes up with no results.
I also checked the mapping , and its in the mapping as "string" no other paramters are set in the mapping for it.

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.