Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve / value from elasticsearch #137

Open
vipermn opened this issue Apr 3, 2020 · 3 comments
Open

Unable to retrieve / value from elasticsearch #137

vipermn opened this issue Apr 3, 2020 · 3 comments
Labels

Comments

@vipermn
Copy link

vipermn commented Apr 3, 2020

I have data stored in elasticsearch by this code that contains a / in the value. Storing the data works fine. However, when I go to retrieve the data, it throws an exception.

Data in Elasticsearch: Townhouse Quad/4 Corners

[main] ERROR com.github.vanroy.springdata.jest.mapper.DefaultErrorMapper - Cannot execute jest action , response code : 400 , error : {"root_cause":[{"type":"query_shard_exception","reason":"Failed to parse query [Townhouse Quad/4 Corners]","index_uuid":"xbMByFnjT66gxUm50vU1mQ","index":"sf"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"sf","node":"Q5vTBSn6SOGFfGr3agUTYw","reason":{"type":"query_shard_exception","reason":"Failed to parse query [Townhouse Quad/4 Corners]","index_uuid":"xbMByFnjT66gxUm50vU1mQ","index":"sf","caused_by":{"type":"parse_exception","reason":"Cannot parse 'Townhouse Quad/4 Corners': Lexical error at line 1, column 25. Encountered: after : "/4 Corners"","caused_by":{"type":"token_mgr_error","reason":"Lexical error at line 1, column 25. Encountered: after : "/4 Corners""}}}}]} , message : null

Any thoughts on how to fix? Like I said, using the library to store the value with the / works just fine.

@VanRoy
Copy link
Owner

VanRoy commented Apr 21, 2020

Hi @viper2846 , can you send me the code of your query ?
Do you have try with direct call to ES ?

@VanRoy VanRoy added the question label May 9, 2020
@VanRoy
Copy link
Owner

VanRoy commented May 9, 2020

@viper2846 Can you provide us an update for this issue ?

@vipermn
Copy link
Author

vipermn commented May 11, 2020

Hi Julien,
Sorry for the slow reply. I was testing and trying things.

Anyway, I am using Elasticsearch 6.8 on AWS. I am using version 3.3.1.RELEASE of the spring-data-jest libraries.

Searching Elasticsearch using the opendistro sql tool through Postman shows that documents return when using an exact match (where propertySubType = 'Townhouse Quad/4 Corners'"). I have to use the keyword syntax to return documents using a like query (where propertySubType.keyword like '%4 Corners%'"). The conclusion is that Elasticsearch itself can return documents when searched containing a forward slash.

On the java side, saving and retrieving documents that contain a field with a forward slash is no issue.

Attempting to search with a propertySubtype parameter value containing a forward slash using the Spring repository throws the error you see in my original issue posting (findByPropertySubType(String propertySubType);) All other Spring repository searches that do not include the propertySubType parameter or do include a propertySubType parameter value without a forward slash return successfully. So a search for another document field (findByStandardStatus(String standardStatus);) or a search for propertySubType without a forward slash value (findByPropertySubType("Single Family Home");) work as expected.

What I discovered the other night is that replacing the forward slash with a space (propertySubType = propertySubType.replace("/", " ");) enables the search to successfully return the correct documents. So effectively searching for "Townhouse Quad 4 Corners" will correctly return documents containing a propertySubtype value of "Townhouse Quad/4 Corners".

Let me know if you need more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants