Hi, i created a profile "No Decay" and a field "product orders" to save the total orders of each product variant in my Drupal Commerce project.

The field is also integrated with the module "Commerce Product Popularity".

I'm trying to use the field as a sort by "Bestsellers" in my search created with search_api + search_api_db + search_api_sorts.

But the field is not displayed in the list of fields available to use as a sort option.

I created a issue in the search_api_sorts module, and the maintainer said "It seems that your value may be natively Fulltext, so you can't use that for sorting."

Look: http://drupal.org/node/1728378

This is the problem? Can we solve this?

Thank you!

Comments

Anonymous’s picture

Status: Active » Postponed (maintainer needs more info)

I cannot reproduce this. I installed radioactivity, setup a basic profile for a node, and indexed with Search API as 'Decimal'. I can see it normally as a Sort option.

By the way, the Radioactivity field is not very useful for Search API: you would need to re-index the node EVERY time the radio-activity changes. Search API will not know when Radioactivity has changed, until it re-indexes all those nodes. So whenever radioactivity changes, you need to add a hook to update the {search_api_item} table... Which is probably very resource intensive on large sites with a lot of radioactive nodes, you won't be able to use it.

brunorios1’s picture

@morningtime,
you tested with drupal commerce?
you created the field in the product variant (entity) or in the product display (node)?

here don't worked with the product variant (entity) but worked with the product display (node).

thank you!

Anonymous’s picture

Ok, no I didn't use the Commerce module...

brunorios1’s picture

ok, i'll try to reproduce in a clean installation and bring more info...

brunorios1’s picture

@morningtime, you said about the re-index EVERY time the radio-activity changes...
you know of any solution to use with search_api that consumes less resources than Radioactivity + search_api?

thanks!

Anonymous’s picture

You could use Search API and do a custom hook_cron() function to tell Search API to reindex all nodes, for example every 24hrs.
But if you need "live radioactivity" results, then you must use a regular View and query the Node fields directly.

brunorios1’s picture

Ok, not so bad...

I don't need so accurate statistics =)

And how can i tell Search API to reindex all nodes with code?
I'm not a coder, so where can i find documentation or a example?

Thank you very much.

Anonymous’s picture

You'll have to find a coder or pay someone to do it then.

brunorios1’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

worked in a clean installation.

sorry for making you lose time!

thanks!

brunorios1’s picture

Status: Closed (works as designed) » Active

i found the reason for the radioactivity field isn't being available for sort and reproduced in a clean installation.

- i have a product display (node)
-- a product reference field (unlimited values)
--- in the product (entity) referenced i have a radioactivity field (single value)

my product reference field accepts unlimited products entities - variations of colors, sizes, prices - and this is good =)

but this is causing the problem about the radioactivity field is not being sorted (note that this problem don't happen with the price field).
if i change the product reference field in the product display to a single value (this is bad), the radioactivity field appears in the sorts list.

any workaround?

ps.: multiple valued fields are not sortable by search_api_sorts. it seems that the radioactivity field is being considered multiple valued even being single valued.

thank you!

Anonymous’s picture

multiple valued fields are not sortable by search_api_sorts

Just to be clear, it's not because of my extension, but because you can't sort on something that has multiple values, It's not possible in the whole universe.

Marbles
1 - Colors: #FFF, #BBB, #AAA
2 - Colors: #AAA, #999, #222
3 - Colors: #111, #333, EEE

How do you sort these marbles by "Color codes"? It's not possible to sort on multi-value fields, unless you calculate an Average or Mean value, or some single value describing the set.

brunorios1’s picture

@morningtime,

sure, my explanation was poorly expressed...

"multiple valued fields are not sortable" would be sufficient =)

sorry!

brunorios1’s picture

Title: Use the radioactivity field as a sort in search with search api » Use a radioactivity field as a sort option using search api and drupal commerce
brunorios1’s picture

Category: support » bug
brunorios1’s picture

Status: Active » Closed (duplicate)
elsteff1385’s picture

Issue summary: View changes

Easily fixed: put this in a custom module named "radioactivity_search_api_reindex"

function radioactivity_search_api_reindex_cron(){
	search_api_index_reindex('NAME_OF_THE_INDEX');
}