I have already read this issue:
#387050: Apache solr and Votingapi

But it looks like it is only targeted at the module "ApacheSolr Integration".

It would be nice if on Search_API/Facet_API we had a facet for listing nodes by minimum votes, minimum rating, etc.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chirhotec’s picture

Subscribing.

I'm using Fivestar on top of Voting API, and really need the ability to filter / sort using Search API and Facet API. I'm not sure which module would be responsible for that, but I'd think it would belong in here and be available to all modules that build on top of Voting API.

Other related threads:

Lukas von Blarer’s picture

Version: master » 7.x-2.x-dev

What I need is a view field for the votes count in a search_api view. What is needed to accomplish this? I would give it a try if someone could point me in the right direction.

Lukas von Blarer’s picture

Status: Active » Needs review
FileSize
844 bytes

I created a first patch that exposes the total votes count. It can easily be extended to expose more entity properties.

AlexSandberg’s picture

The patch works excellent. Thanks A Lot!

torgosPizza’s picture

The patch in #3 works extremely well for me too!

For some reason (not sure if this is due to a recent module update or what), whenever I add the "Average rating" field to Search API's list of Fields to index, I end up with a fatal memory exhaustion error, and the indexing fails.

However with the addition of this property_info_alter() I'm able to index the average value for all nodes and then use this as a value in Search API Sorts, and can successfully sort based on average. Odd, but it works. I've attached my patch here in case anyone wants to look at it, but #3 is RTBC in my opinion.

JimSmith’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

The patches in #3 and #5 work as advertised. Much appreciated!

kyletaylored’s picture

I went ahead and made a combined patch from #3 and #5, just to make application a little easier.

torotil’s picture

Voting api has switched to supporting entities in general not just nodes. This could would work fine for nodes but doesn't for all other entity-types. I would really like to generalize it before it goes into votingapi - and not introduce another node-only feature.

torotil’s picture

Status: Reviewed & tested by the community » Needs review
torotil’s picture

Status: Needs review » Needs work
kopeboy’s picture

What's the state of this?

torotil’s picture

There is a patch that needs generalization from nodes to entities before it can go into votingapi.

Christopher Riley’s picture

Any update on this?

torotil’s picture

As far as I can see: no. I'm still waiting for an entity-based patch for this (see #8). That's the reason why this is set to "needs work".

Sadly so far no one has been sufficiently interested in this feature to provide one.

Christopher Riley’s picture

Thanks for the information. I have a project that I am working on that this functionality would be very useful however I am stuck on a few things. One the above patch limits us to only one vote per node and also the bigger dilemma is what module should have the responsibility for notifying the search api to reindex a item. For example in my instance I am using fivestar for people to rate a product in a comment that is attached to a drupal commerce product display. The comment then adds the rating to the parent node. Should the responsibility fall to the fivestar module to do the reindex command or should it be done on the votingapi end so that there are a larger potential needs filled.

Opions and or feedback?

torotil’s picture

Some thoughts on that:

  • I think if votingapi stores the data it should also be responsible for notifying the search API.
  • I'm also in favor of having votingapi expose all availabe voting-tags and functions. This would expose all of it's capabilities instead of just a use-case specific subset.
Christopher Riley’s picture

Alright one last question before I start trying to wrap my head around the best way to get this done quickly so that I can get the site I am working on launched. Do you think that it should be an additional module or an addition to the core module?

torotil’s picture

I would try to do it as a submodule (votingapi_search?), because it forces us to separate the code clearly and it avoids additional dependencies. Maybe we can integrate the code in the core module as soft-dependency later on.

Christopher Riley’s picture

Alright thanks for the feedback now if I can just make some time to see about getting something implemented quickly. I will keep everyone updated.

k.dani’s picture

I've managed to create a sandbox project for the integration: https://www.drupal.org/sandbox/k.dani/2431227
I'm not sure that my solution is better than the provided patch, but give it a try and feel free to add some feedback.
If it is usable, i'll promote it to full project.

nareshbw’s picture

I am using Apache solr search . But I am unable to use voting api functionality on search page items.

Bohus Ulrych’s picture

Hi torotil,
I understand your point #8 but it seems that everyone is interested in integration with Nodes and not with other entities. After my unsuccessful attempts to find how to do it I found this discussion but it took me few hours. And I suppose that I'm not the only one.
What about to implement patch #7 to the dev version, or at least to put in the README.TXT reference to this thread with subject e.g. "partly Search API integration"?
Thanks

abramm’s picture

I've faced the same issue and made a sandbox project for Entity API integration:
https://www.drupal.org/sandbox/abramm/2748623
The process somewhat reverse to what patches above does; the idea is to expose votes as entities so the votes may be indexed.