2

I have indexed a number of file paths into elastic search without without setting any mappings, so I'm letting elasticsearch detect the field types. It has detected this field as {"type" : "string"} which would appear to be ok. The file paths are:

/file/file1
/file/file2
/file/file5
/file/file3
/file/file4

When I do a query and tell it to sort on the file path, the file paths are returned in their original order and it appears that they all receive the same sort value. Is this an issue caused by not setting a mapping? How can I get elasticsearch to sort these values in the correct order?

1 Answer 1

3

I think you can try mapping that filed to be

{
    "type":  "string",
    "index": "not_analyzed"
}
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I just tried to apply that mapping, however I get an error that "merge failed with failures {[mapper [filepath] has different [index] values" and that the merge failed and I cannot changed from disabled to enabled. Any suggestions?
I deleted the index, applied the mapping and now it works great! I thought it was possible to modify the mapping with data already loaded, do you know if that's possible?
Yeah it is possible but you have to close your index first then you can change the mapping. However, the moment you are closing your index, no query can be apply means it is the same like you delete the index and re-create it. It's just faster to close and re-open in fact

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.