Sorting by custom function query

2014-05-15 Thread Emanuele Filannino
Hi there,

I'm running into some issues developing a custom function query using Solr 
3.6.2.
My goal is to be able to implement a custom sorting technique.

I have a field called daily_prices_str, it is a single value str.

Example:

str name=daily_prices_str
2014-05-01:130 2014-05-02:130 2014-05-03:130 2014-05-04:130 2014-05-05:130 
2014-05-06:130 2014-05-07:130 2014-05-08:130 2014-05-09:130 2014-05-10:130 
2014-05-11:130 2014-05-12:130 2014-05-13:130 2014-05-14:130 2014-05-15:130 
2014-05-16:130 2014-05-17:130 2014-05-18:130 2014-05-19:130 2014-05-20:130 
2014-05-21:130 2014-05-22:130 2014-05-23:130 2014-05-24:130 2014-05-25:130 
2014-05-26:130 2014-05-27:130 2014-05-28:130 2014-05-29:130 2014-05-30:130 
2014-05-31:130 2014-06-01:130 2014-06-02:130 2014-06-03:130 2014-06-04:130 
2014-06-05:130 2014-06-06:130 2014-06-07:130 2014-06-08:130 2014-06-09:130 
2014-06-10:130 2014-06-11:130 2014-06-12:130 2014-06-13:130 2014-06-14:130 
2014-06-15:130 2014-06-16:130 2014-06-17:130 2014-06-18:130 2014-06-19:130 
2014-06-20:130 2014-06-21:130 2014-06-22:130 2014-06-23:130 2014-06-24:130 
2014-06-25:130 2014-06-26:130 2014-06-27:130 2014-06-28:130 2014-06-29:130 
2014-06-30:130 2014-07-01:130 2014-07-02:130 2014-07-03:130 2014-07-04:130 
2014-07-05:130 2014-07-06:130 2014-07-07:130 2014-07-08:130 2014-07-09:130 
2014-07-10:130 2014-07-11:130 2014-07-12:130 2014-07-13:130 2014-07-14:130 
2014-07-15:130 2014-07-16:130 2014-07-17:130 2014-07-18:130 2014-07-19:170 
2014-07-20:170 2014-07-21:170 2014-07-22:170 2014-07-23:170 2014-07-24:170 
2014-07-25:170 2014-07-26:170 2014-07-27:170 2014-07-28:170 2014-07-29:170 
2014-07-30:170 2014-07-31:170 2014-08-01:170 2014-08-02:170 2014-08-03:170 
2014-08-04:170 2014-08-05:170 2014-08-06:170 2014-08-07:170 2014-08-08:170 
2014-08-09:170 2014-08-10:170 2014-08-11:170 2014-08-12:170 2014-08-13:170 
2014-08-14:170 2014-08-15:170 2014-08-16:170 2014-08-17:170 2014-08-18:170 
2014-08-19:170 2014-08-20:170 2014-08-21:170 2014-08-22:170 2014-08-23:170 
2014-08-24:170 2014-08-25:170 2014-08-26:170 2014-08-27:170 2014-08-28:170 
2014-08-29:170 2014-08-30:170
/str

As you can see the structure of the string is date:price.

Basically, I would like to parse the string to get the price for a particular 
period and sort by that price.
I’ve already developed the java plugin for the custom function query and I’m at 
the point where my code compiles, runs, executes, etc. Solr is happy with my 
code.

Example:
price(daily_prices_str,2015-01-01,2015-01-03)

If I run this query I can see the correct price in the score field:

/select?price=price(daily_prices_str,2015-01-01,2015-01-03)q={!func}$price

One of the problems is that I cannot sort by function result.
If I run this query:

/select?price=price(daily_prices_str,2015-01-01,2015-01-03)q={!func}$pricesort=$price+asc

I get a 404 saying that sort param could not be parsed as a query, and is not 
a field that exists in the index: $price
But it works with a workaround:

/select?price=sum(0,price(daily_prices_str,2015-01-01,2015-01-03))q={!func}$pricesort=$price+asc

The main problem is that I cannot filter by range:

/select?price=sum(0,price(daily_prices_str,2015-1-1,2015-1-3))q={!frange l=100 
u=400}$price

Maybe I'm going about this totally incorrectly?


This message has been scanned for malware by Websense. www.websense.com


Sorting by custom function query

2014-05-12 Thread Emanuele Filannino
Hi there,


I'm running into some issues developing a custom function query using Solr
3.6.2.

My goal is to be able to implement a custom sorting technique.


I have a field called daily_prices_str, it is a single value str.


Example:


str name=daily_prices_str

2014-05-01:130 2014-05-02:130 2014-05-03:130 2014-05-04:130 2014-05-05:130
2014-05-06:130 2014-05-07:130 2014-05-08:130 2014-05-09:130 2014-05-10:130
2014-05-11:130 2014-05-12:130 2014-05-13:130 2014-05-14:130 2014-05-15:130
2014-05-16:130 2014-05-17:130 2014-05-18:130 2014-05-19:130 2014-05-20:130
2014-05-21:130 2014-05-22:130 2014-05-23:130 2014-05-24:130 2014-05-25:130
2014-05-26:130 2014-05-27:130 2014-05-28:130 2014-05-29:130 2014-05-30:130
2014-05-31:130 2014-06-01:130 2014-06-02:130 2014-06-03:130 2014-06-04:130
2014-06-05:130 2014-06-06:130 2014-06-07:130 2014-06-08:130 2014-06-09:130
2014-06-10:130 2014-06-11:130 2014-06-12:130 2014-06-13:130 2014-06-14:130
2014-06-15:130 2014-06-16:130 2014-06-17:130 2014-06-18:130 2014-06-19:130
2014-06-20:130 2014-06-21:130 2014-06-22:130 2014-06-23:130 2014-06-24:130
2014-06-25:130 2014-06-26:130 2014-06-27:130 2014-06-28:130 2014-06-29:130
2014-06-30:130 2014-07-01:130 2014-07-02:130 2014-07-03:130 2014-07-04:130
2014-07-05:130 2014-07-06:130 2014-07-07:130 2014-07-08:130 2014-07-09:130
2014-07-10:130 2014-07-11:130 2014-07-12:130 2014-07-13:130 2014-07-14:130
2014-07-15:130 2014-07-16:130 2014-07-17:130 2014-07-18:130 2014-07-19:170
2014-07-20:170 2014-07-21:170 2014-07-22:170 2014-07-23:170 2014-07-24:170
2014-07-25:170 2014-07-26:170 2014-07-27:170 2014-07-28:170 2014-07-29:170
2014-07-30:170 2014-07-31:170 2014-08-01:170 2014-08-02:170 2014-08-03:170
2014-08-04:170 2014-08-05:170 2014-08-06:170 2014-08-07:170 2014-08-08:170
2014-08-09:170 2014-08-10:170 2014-08-11:170 2014-08-12:170 2014-08-13:170
2014-08-14:170 2014-08-15:170 2014-08-16:170 2014-08-17:170 2014-08-18:170
2014-08-19:170 2014-08-20:170 2014-08-21:170 2014-08-22:170 2014-08-23:170
2014-08-24:170 2014-08-25:170 2014-08-26:170 2014-08-27:170 2014-08-28:170
2014-08-29:170 2014-08-30:170

/str


As you can see the structure of the string is date:price.


Basically, I would like to parse the string to get the price for a
particular period and sort by that price.

I’ve already developed the java plugin for the custom function query and
I’m at the point where my code compiles, runs, executes, etc. Solr is happy
with my code.


Example:

price(daily_prices_str,2015-01-01,2015-01-03)


If I run this query I can see the correct price in the score field:


/select?price=price(daily_prices_str,2015-01-01,2015-01-03)q={!func}$price


One of the problems is that I cannot sort by function result.

If I run this query:


/select?price=price(daily_prices_str,2015-01-01,2015-01-03)q={!func}$pricesort=$price+asc


I get a 404 saying that sort param could not be parsed as a query, and is
not a field that exists in the index: $price

But it works with a workaround:


/select?price=sum(0,price(daily_prices_str,2015-01-01,2015-01-03))q={!func}$pricesort=$price+asc


The main problem is that I cannot filter by range:


/select?price=sum(0,price(daily_prices_str,2015-1-1,2015-1-3))q={!frange
l=100 u=400}$price


Maybe I'm going about this totally incorrectly?