You are currently viewing the "Outline" mode of a pure HTML presentation developed using S5. To view the presentation as a slide show, you can click the ± in the upper right hand corner of the page. To control the slideshow, mouse over the lower section of the screen to make the HUD controls visible, or hit space to advance the slides.

A Zip file containing all of these slides, as well as the demo files for the example is available.

NOTE: Updated information about the technique discussed in these slides has been posted on the Solr wiki. Please review the advice/examples there before attempting to implement any of these ideas in a real world situation. The configuration examples on these slides are not recomended.

This help text will be hidden when printing this presentation.

Spatial Search Tricks for People Who Don't Have Spatial Data

Chris Hostetter

2013-01-17 MeetUp


Intro: Solr4 Spatial

<field name="zone"> POLYGON((9 33, 41 42, 35 4, 11 23, 2 15)) </field>
q = zone:"Intersects(10 15 22 30)"

Modeling Data With Coordinates

Time Duration Data

Semi-Common Problems



Area Intersections To The Rescue!

The big caveat here is that -∞ and ∞ are not actually supported, you must have lower and upper bounds on your coordinate space.


Totally Realistic Government Usecase

There is a demo directory with solr configs and sample data for this example.

Data Model

<fieldType name="days_of_year" class="solr.SpatialRecursivePrefixTreeFieldType" multiValued="true" geo="false" worldBounds="0 0 365 365" distErrPct="0" maxDistErr="0.00000009" units="degrees" />

Sample Data

<doc> <field name="id">1</field> <field name="name">Adam Anderson</field> <field name="rank">6</field> <field name="dept">astronomy</field> <field name="shift">1 3</field> <field name="shift">5 7</field> <field name="shift">10 15</field> ...

Sample Data

Diagram generated using a gnuplot script.

Query: Contains

Personnel on shift continuously from Jan8-9

"Find the senior astronomers on shift during the next alien eclipse to put them in chage of the project to observe it."

q = shift:"Intersects(0 9 8 365)" fq = dept:astronomy sort = rank asc rows = 1

Query URL using the provided demo files.

Query: Contains

Diagram generated using a gnuplot script.

Query: Overlaps

Personnel on shift sometime overlapping Jan19-23

"Email blast everyone who will be on duty during the alien overloard's diplomatic visit reminding them to be on their best behavior."

q = shift:"Intersects(0 19 23 365)"

Query URL using the provided demo files.

Query: Overlaps

Diagram generated using a gnuplot script.

Query: Within

People on duty for some period starting after Jan6 and ending by Jan10

"Find someone to courier these time sensitive treaty documents; they must be taken to the alien capital after the president signs them, and the response needs to be brought back before the next UN summit."

q = shift:"Intersects(6 0 365 10)" sort = rank asc

Query URL using the provided demo files.

Query: Within

Diagram generated using a gnuplot script.




This durration modeling as coordinates idea originated in a solr-user@lucene thread. See David's initial response to Geert-Jan's question and the subsequent followup about using differnt rectangle intersections.