Hi Matt.

The documentation is here:
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4

The sort / relevancy section is a TODO; I've been improving this document 
lately a bit at a time lately.
 
My comments are within...

On Oct 5, 2012, at 10:10 AM, Matt Mitchell wrote:

> Hi,
> 
> Apologies if some of this has been asked before. I searched the list,
> found similar questions but the suggestions didn't solve my issues.
> 
> I've been playing with the new spatial features in Solr trunk, very
> cool. I successfully indexed a MULTIPOLYGON and could see my query
> working using the "Intersects" function <- that is very exciting! My
> question is, how can I find out more info on this stuff? Some of the
> things I'm looking for, specifically:
> 
> What functions are available? For example, is there a "contains"
> function? Is there java source-code I could look at to figure out
> what's available?

SpatialOperation.java.  For what's in Lucene / Solr 4.0, the only operation 
that is effectively implemented right now is INTERSECTS.  WITHIN is supported 
by PointVector field type but that is semantically equivalent to INTERSECTS 
when the indexed data is Points, and PointVector as its name suggests only 
supports points.  In the future, I figure my employer will have the need for a 
WITHIN and CONTAINS operation, and I know how to add that to the 
RecursivePrefixTree based field types.  It won't be easy.  I believe Chris Male 
has already done this on the ElasticSearch port of Lucene spatial, but I 
haven't looked at it.

> Is there a way to dynamically buffer a geometry, then query on that
> buffered geometry?

I have this at work but it's not yet in the open-source offering.  It's pretty 
easy thanks to JTS, which does the hard work (it's just a method call).  Once 
we get an open-source extensible WKT parser in Spatial4j (which Chris has 
already done for ElasticSearch, so it's going to happen in the very near 
future), we can then add a buffer operation.

> Can I get the distance (as a pseudo field) to a stored/indexed
> MULTIPOLYGON from a given point?

If you are already sorting it, then see the example below (notice the "distdeg" 
pseudo-field alias).  The solution below will work even if you don't sort it 
but it will trigger RAM requirements that are a bit needless.  If you don't 
want the RAM requirements, then you should perform this calculation yourself at 
the client.

> What about sorting by distance to MULTIPOLYGON from point?

Yes... though I'm not happy with the implementation.  I recommend you index a 
field just for the center point.  If there is going to be only one per 
document, then use PointVector or LatLonType.  If there is multiple... then 
you're stuck with the existing implementation with seems to work but definitely 
isn't scalable for real-time-search nor for millions of documents or more.

Here's a comment on the JIRA issue where I left an example:
https://issues.apache.org/jira/browse/SOLR-3304?focusedCommentId=13456188&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13456188

That query is:
http://localhost:8983/solr/select?q=*%3A*&wt=xml&fq={!%20v=$sq}&sq=store:%22Intersects%28Circle%2854.729696,-98.525391%20d=10%29%29%22&debugQuery=on&sort=query%28$sortsq%29+asc&fl=id,store,score,distdeg:query%28$sortsq%29&sortsq={!%20score=distance%20v=$sq}

> Can or will it be possible to transform shapes, for example select the
> minimum-bounding-box of a complex shape? Another example would be
> extracting the center point of a polygon.

BBox of an indexed shape is not really supported so you'd have to index the 
bbox as a rectangle, probably via Lucene 5 spatial BBoxStrategy.

For a query shape... that is one of those operations, like a buffer, that I'd 
like to add.

> I've tried to sort and get the distance using some of the tips on the
> Wiki, but couldn't get any of it to work.
> 
> I'd be glad to get some of this into the Wiki too.

Just to repeat:

The documentation is here:
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4

~ David

Reply via email to