This is a spinoff from #1064884: Add support for indexing non-entities

In order to use data from apachesolr (data that Search API didn't write), I need to be able to get information about what fields the Solr/Lucene index is storing.

Apache Solr provides this functionality with the "luke" servlet.

I've been working in a branch called 'party-integration' in a clone of search_api_solr on github: https://github.com/palantirnet/search_api_solr -- my initial patch is in commit ed4aae.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Title: Get information about a solr index (patch) » Add support for the Luke request handler
Status: Active » Fixed

Looks great, thanks! Committed.

becw’s picture

Thanks! That was so quick!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

becw’s picture

Status: Closed (fixed) » Active
FileSize
6.99 KB

In using this, I found that some revisions were necessary to make it more useful:

  • The SearchApiSolrService::getFields() method was fetching from cache_get() every time it was called. Oops.
  • It's really useful to have a class to handle logic around Solr fields, like "is this field multivalued?" or "does it make sense to sort on this field?"
  • Here's a patch.

drunken monkey’s picture

Status: Active » Needs work

Nice addition, thanks!
A few things, though:

  • As the field class isn't coupled that tightly to the service class, it should go into a new file.
  • Should getFields() really use $this->fields when $reset is set? In my opinion, it should then also not use the static cache. As it is, $reset = TRUE won't have any effect if the method was called previously in the same request, which might lead to unwanted stale caches.
  • Please use
    @return TYPE
      DESCRIPTION

    for documenting the return values, as this is used in the rest of the module (and also, I think, in core).
    Please also update the documentation for the two methods in the connection class.

becw’s picture

Status: Needs work » Needs review
FileSize
8.09 KB

Ok, here's an updated patch:

  • The SolrField class is in a new file.
  • The SearchApiSolrService::getFields() method is updated--you're right, that was unintentional behavior.
  • Documentation is updated.

Thanks for the careful review!

drunken monkey’s picture

Looks quite good already, thanks for revising!
A few corrections still, see the attached patch:
- Properly namespace the field class as SearchApiSolrField.
- I don't thin the cache ID needs to be a property, as it is used in only one method – removed the property.
- Some small comment fixes.
Otherwise, exemplary. ;) If you don't have any objections, I'll commit the attached patch.

becw’s picture

Hmm, this patch isn't working for me... I must have screwed something up in #4. I'm looking into it.

drunken monkey’s picture

For me, everything works fine. Did you clear the cache?
Otherwise, yes, please look into it.

becw’s picture

Status: Needs review » Reviewed & tested by the community

My problems were coming from somewhere else. This patch looks good to go. Thanks!

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

OK, great. Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.