Solr: How to index range-pair fields?

2015-08-20 Thread vaedama
My scenario is something like this:

I have a students database. I want to query all the students who were either
`absent` or `present` during a particular `date-range`.

For example:

Student "X" was `absent` between dates:

 Jan 1, 2015 and Jan 15, 2015
 Feb 13, 2015 and Feb 16, 2015
 March 19, 2015 and March 25, 2015

Also "X" was `present` between dates:

 Jan 25, 2015 and Jan 30, 2015
 Feb 1, 2015 and Feb 12, 2015

(Other days were either school holidays or the teacher was either
lazy/forgot to take the attendance ;)

If the date range was only a single-valued field then this approach would
work:
http://stackoverflow.com/questions/25246204/solr-query-for-documents-whose-from-to-date-range-contains-the-user-input.
I have multiple-date ranges for each student, so this would not work for my
use-case.

Lucent 5.0 has support for `DateRangeField`
(http://lucene.apache.org/solr/5_0_0/solr-core/index.html?org/apache/solr/schema/DateRangeField.html
) which is perfect for my use-case, but I cannot upgrade to 5.0 yet! I am on
Lucene 4.1.0. David Smiley had mentioned that it would be ported to 4.x but
I guess it never happened (https://issues.apache.org/jira/browse/SOLR-6103,
I can try porting this patch my-self but I would like to know what it takes
and opinions)

So basically, I need to maintain relationship between the start and end
dates for each of the `state`s (absence or presence). So I thought I would
need to index the fields as pairs as mentioned here:
http://grokbase.com/t/lucene/solr-user/128r96vwz6/how-do-i-represent-a-group-of-customer-key-value-pairs

I guess my schema would look like:









**Question #1:** Does this look correct ? 

**Question #2:** What are the ramifications if I use `tlong` instead of
`tdate` ? My `tlong` type looks like this:



**Question #3:** So in this case, for the query: "get all the students who
were absent between a date range" would the query would look something
similar to this ?

(state: absent) AND 
(absenceStartTime1: givenLowerBoundDate) AND
(absenceStartTime2: givenLowerBoundDate) AND
(absenceStartTime3: givenLowerBoundDate) AND
(absenceEndTime1: givenUpperBoundDate) AND
(absenceEndTime2: givenUpperBoundDate) AND
(absenceEndTime3: givenUpperBoundDate)


This would work only if I knew that there were 3 dates in which the student
was absent before hand and there's no way to query all dynamic fields with
wild-cards according to
http://stackoverflow.com/questions/6213184/solr-search-query-for-dynamic-fields-indexed

**Question #4:** The workaround mentioned in one of the answers in that
question did not look terrible but seemed a bit complicated. Is there a
better alternative for solving this problem in Solr ?

Of course, I would be highly interested in any other better approaches.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-How-to-index-range-pair-fields-tp4224369.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Solr: How to index range-pair fields?

2015-08-21 Thread vaedama
Hi Alexandre,

Thanks for your reply!

I guess these are the links that you were referring to :)

http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201212.mbox/%3c1354991310424-4025359.p...@n3.nabble.com%3E
https://wiki.apache.org/solr/SpatialForTimeDurations
https://people.apache.org/~hossman/spatial-for-non-spatial-meetup-20130117/

That would work if the time ranges were days_of_year. But I want to also
maintain the timestamp level granularity. Apologies for not mentioning that
in my earlier email.

Thanks,
Venkat Sudheer Reddy Aedama



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-How-to-index-range-pair-fields-tp4224369p4224508.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Solr: How to index range-pair fields?

2015-08-21 Thread vaedama
Hello Eric,

Thanks for your reply. 

"You can always index to a second field with "date math", or 
even pull out the day as you're indexing. "

How would this second field look like ? Can you please provide me an example
for both  definition and  definition ?

Also, please tell me how would my query fit into this ? Specifically, my
use-case is CONTAINS (I do not care about INTERSECT or WITHIN).

Thanks in advance.



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-How-to-index-range-pair-fields-tp4224369p4224520.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Solr: How to index range-pair fields?

2015-08-21 Thread vaedama
Alexandre,

How would the data type look like ?

Currently, this is what I have:



   
   
   http://lucene.472066.n3.nabble.com/Solr-How-to-index-range-pair-fields-tp4224369p4224526.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Solr: How to index range-pair fields?

2015-08-21 Thread vaedama
Alexandre,

Fantastic answer! I think having a start position would work nicely with my
use-case :) Also I would prefer to do the date Math during indexing.

*Question # 1:* Can you please tell me if this doc looks correct (given that
I am not yet bothered about factoring in "year" into my use-case) ?

Student "X" was `absent` between dates:

 Jan 1, 2015 and Jan 15, 2015 
 Feb 13, 2015 and Feb 16, 2015 (assuming that Feb 13 is 43rd day in the
year 2015 and Feb 16 is 46th day)
 March 19, 2015 and March 25, 2015 

Also "X" was `present` between dates: 

 Jan 25, 2015 and Jan 30, 2015 
 Feb 1, 2015 and Feb 12, 2015

{ 
  id: "X", 
  state: ["absent", "present"],
  presentDays: [ [01 15 366 366], [43, 46, 366, 366], [78, 84, 366, 366] ],
  absentDays: [ [25, 30, 366, 366],  [32, 43, 366, 366] ] 
} 

*Question #2:*

Since I need timestamp level granularity, what is the appropriate way to
store the field ?

Student "X" was `absent` between epoch times:

 1420104600 (9:30 AM, Jan 1 2015) and 1421341200 (5:00 PM, Jan 15, 2015)

Is it possible to change *worldBounds* to take a polygon structure where I
can represent millisecond level granularity ?

Thanks in advance,
Venkat Sudheer Reddy Aedama




--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-How-to-index-range-pair-fields-tp4224369p4224582.html
Sent from the Solr - User mailing list archive at Nabble.com.


Solr search with various combinations of space, hyphen, casing and punctuations

2015-04-21 Thread vaedama
I posted this question on Stackoverflow, but wanted to get this to some
attention of Solr mailing lists as well:
http://stackoverflow.com/questions/29783237/solr-search-with-various-combinations-of-space-hyphen-casing-and-punctuations

Thanks in advance,
Venkat Sudheer Reddy Aedama



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-search-with-various-combinations-of-space-hyphen-casing-and-punctuations-tp4201405.html
Sent from the Solr - User mailing list archive at Nabble.com.