Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
A project to create a Great Geo-Spatial Search Experience for Drupal 8 users has been selected this year in Google Summer Of Code and we are on the way to make it successful. Currently we are trying to add a new feature to facets i.e a map as facet filter to narrow down results by dragging and zooming it. You can have a look on this issue as well. We are following this blog extensively to visuliaze milions of Geonames on a map. To achieve the same, search Api Solr needs to support SpatialRecursivePrefixTreeFieldType with adding some Spatial query and features to SearchAPiSolrBackend.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#32 | 2901630_32.patch | 12.16 KB | mkalkbrenner |
Comments
Comment #2
dbjpanda CreditAttribution: dbjpanda commentedSubmitted the patch which adds support of rpt data type and also solves the issue https://www.drupal.org/node/2892620#comment-12217677 . Kindly review.
Comment #3
dbjpanda CreditAttribution: dbjpanda commentedIgnore the patch #2
Comment #4
mkalkbrennerInteresting :-)
Some quick notes on the patch:
Is there an issue for Search API to declare these features?
Aren't these data types?
What do you mean exactly?
Beside these there're a lot of todos in the code ;-)
I think the most important missing piece is a test. Have a look at the existing tests for location search. Using travis it is easy to apply patches to any module required in this test and to provide an integration test even in this early stage. Simply fork https://github.com/mkalkbrenner/search_api_solr and start PRs to start the tests. Do you need help with that?
Comment #5
Nick_vhThe datatypes are supported by the search_api_location module as you can see in the latest patch there. https://www.drupal.org/node/2892620#comment-12217677
The solr patch has been tested there so that it works as expected. There is currently no search_api_db support for those datatypes yet and I'm doubting if it should be part of the requirement before this can be committed. The test obviously is a requirement :)
As for search_api, I don't think it needs to declare these features anywhere as they are only supported in search_api_solr backend. Each backend can define new features to support so no patch for search_api itself is needed (I think).
Comment #6
dbjpanda CreditAttribution: dbjpanda commentedCleaned the SearchApisolrBackened code and added an intermidiatory test.
Comment #7
mkalkbrennerIs that true?
a missing space
Is there a minimum Solr version required for that?
The new test class is not required. The purpose of the existing class SearchApiLocationTest is to test the integration with the Search API Location module. Therefore it's sufficient to add this line to the existing class to have a location and a rpt field.
Have a look at SearchApiSolrLocationTest::testBackend(). I guess you could simply add some more queries to it to test the rpt field.
Comment #8
dbjpanda CreditAttribution: dbjpanda commentedAhh..I tried to run SearchApiLocationTest but it does not show green both on my Local and Travis
Comment #9
Nick_vh#3 Minimum Solr 5.1. No schema modifications needed.
Comment #10
borisson_We decided to not support heatmaps in the patch in location, so no tests for this either, we can remove this part I think.
Comment #11
dbjpanda CreditAttribution: dbjpanda commented@borisson_ We had decided to remove geohash. Heatmap is the main stuff that is our project based on. We are plotting extracted heatmap layer on a web map like leaflet.
Comment #12
drunken monkeyAs Markus said, "rpt" is a data type, no need to also define it as a feature.
Comment #13
mkalkbrenner@drunken monkey: Isn't this a "data-type-feature" as well? ;-)
@dbjpanda: My comments from #7 are still valid. based on Nick's comment in #9 we should wrap some parts of the patch with a Solr version check.
Comment #14
dbjpanda CreditAttribution: dbjpanda commented1- I found a lot of coding standard errors, So I tried to fix most of those in this patch including those pointed out in #7.
2- I tried to write a test for RPT type but I am not successful though. In case anyone wants to try, first he has to create a solr instance named as "d8" .
3- #7 Yes Its true.
4- @toDo write tests for searchApiSolrBackend in SearchApiSolrLocationTest::testBackend() indexing location as rpt data type. And as this feature only supported by Solr 5.1 there should be a version check functionality as well.
Comment #15
mkalkbrennerThanks for pointing out the coding standards violations. We should definitely fix them. But this should be done in separate issue because the patch isn't easy to read and understand anymore. a feature patch should focus only on the feature itself.
Yes, the tests require a "d8" core on localhost. But the module contains a docker-compose file for easy test setup.
Comment #16
dbjpanda CreditAttribution: dbjpanda commentedComment #17
dbjpanda CreditAttribution: dbjpanda commented1- Fixed all issue pointed out in #7
2- Test shows green on my local as well.
Kindly review.
Comment #18
mkalkbrennerGreat progress an I I think we're getting closer :-)
drunken monkey suggested to remove this feature definition entirely in #12.
Throwing an exception isn't the appropriate way here. I prefer to write a log message and to let the code continue. In this case it should visually lead to zero results.
new code should follow the coding standards ;-)
The comment is wrong. It's a static field name prefix and not a dynamically defined one.
rpt spatial
typo: spatial
rpt spatial options
Thrown if more than one is added.
I think there's no need to pass the $rpt_options as reference.
save() should only be called once.
It would be good to add additional test queries that don't use the default and that return more than one result.
Comment #19
dbjpanda CreditAttribution: dbjpanda commentedComment #20
dbjpanda CreditAttribution: dbjpanda commentedComment #21
dbjpanda CreditAttribution: dbjpanda commentedSorry ignore the above patch. One more coding standard was to fix. :)
Comment #22
mkalkbrennercoding standard ;-)
These two assertions will fail on Solr 4 which is still part of our CI on travis.
Therefore these two assertions needs to be wrapped by a version check.
You can use §this->getServer()->getBackend()->getSolrConnector()->getSolrVersion().
What does this count mean? It looks a bit confusing to have two results and a count of 1.
Comment #23
dbjpanda CreditAttribution: dbjpanda commentedKindly review. Fixed issues pointed out in #22.
Comment #24
mkalkbrennerIt would be nice to add interdiffs every time you upload an adjusted patch. That would ease the review a lot.
I suggest to detect the Solr version only once, store it in a variable and then comparetwo times against the variable.
The implemented check itself is wrong, greater than float 5.1 doesn't work in all cases. For example 5.10 is greater than 5.1 as a version but not mathematical.
You have to use version_compare() like in the backend class.
We should add the else part and an assertion that verifies the log message about the wrong Solr version.
If we fix the findings in the test above, we're ready to commit your patch :-)
Which patches to other modules are required exactly to get the tests to pass?
Comment #25
mkalkbrennerComment #26
mkalkbrennerComment #27
dbjpanda CreditAttribution: dbjpanda commentedComment #28
dbjpanda CreditAttribution: dbjpanda commentedComment #29
dbjpanda CreditAttribution: dbjpanda commentedModified the patch little bit by removing the below code snippets as it does not belongs to this issue and already rectified by Markus before some hours today. :)
Comment #30
mkalkbrennerI added an assertion for the log messages if Solr is older than 5.1.
The tests now pass on Solr 5 and 6:
https://travis-ci.org/mkalkbrenner/search_api_solr/builds/267696702
(They are not green because of the currently failing autocomplete tests.)
But for Solr 4 the tests fail:
Undefined index: rpt
I think this line is causing the error:
This code has to be moved to under the version detection because there can't be a key 'rpt' on a empty Solr 4 result. Anyway, accessing the result this way is a kind of unsafe.
Comment #31
mkalkbrennerComment #32
mkalkbrennerThe location tests look good now:
https://travis-ci.org/mkalkbrenner/search_api_solr/builds/267870596
I attached the final patch and will merge the branch.
Comment #34
dbjpanda CreditAttribution: dbjpanda commentedI had already sent you a PR https://github.com/dbjpanda/search_api_solr/commit/c0590cab448b92e42e867... in Github yesterday with above changes. So exactly where should I start contributing for search_api_solr further in github or D.O issue queue ?
By the way thanks Markus and other contributors for your valuable time.
Comment #35
mkalkbrennerIt's a little bit complicated caused by the fact that we can't run Solr test on drupal.org infrastructure.
All the communication has to happen here on drupal.org in order to be visible and transparent for everyone.
Every patch that is reviewed here on drupal.org get committed to github first to let travis execute the tests. If they pass I merge the commit from github to drupal.org.
If you want to leverage travis it the easiest way to provide a Pull Request on github to get a patch tested. But one it's ready, you should post the patch here in the issue queue to satisfy to process described above.