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

Search API Solr unsets the ID field from each result #3

Open
DavidACameron-USDA opened this issue Apr 7, 2017 · 4 comments
Open

Search API Solr unsets the ID field from each result #3

DavidACameron-USDA opened this issue Apr 7, 2017 · 4 comments
Labels

Comments

@DavidACameron-USDA
Copy link
Owner

It assumes that each record has a 'search_api_id' field. Presumably, this field is included in all records that are indexed by Search API Solr. SAS looks for this field on every request. After it's done extracting results from the response, it unsets the field from the results array.

The datasource (well, the mapping alter hook in the .module file) maps the configured ID field to the 'search_api_id' key since SAS throws errors if that key isn't found. Then it gets unset. This prevents the ID field from being used in displays.

I've attempted to fix this by aliasing the configured ID field to 'search_api_id,' but that didn't work for me. I hoped Solr would duplicate the ID field to it and output both in the response, but it won't. It just renames the ID field.

@DavidACameron-USDA
Copy link
Owner Author

DavidACameron-USDA commented Apr 13, 2017

I created a support request to see if one of the Search API Solr maintainers had any idea about what to do. I'm nearly out of ideas. I think the best solution will be to extend the backend plugin and create our own that overrides extractResults(). I don't want to do that and create more configuration steps in order to get this up and running. Also, I just want to keep this code base smaller without adding another plugin if it's at all possible.

@DavidACameron-USDA
Copy link
Owner Author

Per https://www.drupal.org/node/2869267#comment-12037079, SAS provides the ID property for each result Item in a unique field in Views. I was concerned that it wouldn't return the raw ID and instead give a slightly edited version, but apparently it does give the raw one. Yay!

We will have to document that people need to use this field instead of the raw field (ambiguous terminology sucks) from Solr, but at least there is a workaround. I'm leaving this issue open as a reminder to document it.

It might be worthwhile to prevent the ID field from being listed in the index's fields. I'm not sure if this would just cause confusion for site builders. Also, if a way can be found to limit the field list in Views then it should be removed there too.

@drunken-monkey
Copy link

I've posted a patch to the Solr issue that should fix this problem.

@DavidACameron-USDA
Copy link
Owner Author

I think that might work. I'll test it later when I get a chance. Thanks!

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