lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Smiley (@MITRE.org)" <DSMI...@mitre.org>
Subject Re: Solr 4.1: problems with Spatial Search.
Date Wed, 06 Mar 2013 14:48:27 GMT
Ah; bingo!

The top error in the log is what Solr reports in the HTTP response you
reported but it's the message of the exception wrapped by it in the logs
which is more indicative of the problem:

Caused by: org.apache.solr.common.SolrException: A ValueSource isn't
directly available from this field. Instead try a query using the distance
as the score.

That error message (which I wrote) even contains the solution :-)

You're using geodist() against solr.SpatialRecursivePrefixTreeFieldType
which isn't supported.  You can get the distance but not using that
approach.  Instead the query itself returns the distance as the score.  In
the example schema you'll see a link to documentation about this field type
which is this URL:
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
>From there click on "Sorting and Relevancy":
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4#Sorting_and_Relevancy
And you'll see an example query along the lines of what you want:
&fl=*,score&sort=score asc&q={!
score=distance}geo:"Intersects(Circle(54.729696,-98.525391 d=10))" 
(the score is the distance in this case)

~ David


Rakudten wrote
> Hello everyone!
> 
>    - I´m using Solr 4.1.0.
> 
> 
>    - Yes, without the sort the query works perfectly.
> 
> 
>    - The fieldType is as follows:
> 
>          
> <field name="geolocation" type="location_rpt" indexed="true"
> stored="true" multiValued="true" />
> *    *
>             
> <fieldType name="location_rpt"
> class="solr.SpatialRecursivePrefixTreeFieldType"
> 
> 
> spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
>                distErrPct="0.025"
>                maxDistErr="0.000009"
>                units="degrees"
>          />
>    - The error trace from Solr:
> 
> Mar 6, 2013 10:02:29 AM org.apache.solr.common.SolrException log
> SEVERE: org.apache.solr.common.SolrException: sort param could not be
> parsed as a query, and is not a field that exists in the index: geodist()
> at org.apache.solr.search.QueryParsing.parseSort(QueryParsing.java:340)
> at org.apache.solr.search.QParser.getSort(QParser.java:281)
> at
> org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:123)
> at
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:187)
> at
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1816)
> at
> org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:448)
> at
> org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:269)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
> at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
> at
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: org.apache.solr.common.SolrException: A ValueSource isn't
> directly available from this field. Instead try a query using the distance
> as the score.
> at
> org.apache.solr.schema.AbstractSpatialFieldType.getValueSource(AbstractSpatialFieldType.java:219)
> at
> org.apache.solr.search.function.distance.HaversineConstFunction.parseSfield(HaversineConstFunction.java:168)
> at
> org.apache.solr.search.function.distance.HaversineConstFunction.access$200(HaversineConstFunction.java:47)
> at
> org.apache.solr.search.function.distance.HaversineConstFunction$1.parse(HaversineConstFunction.java:104)
> at
> org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.java:352)
> at org.apache.solr.search.FunctionQParser.parse(FunctionQParser.java:68)
> at org.apache.solr.search.QParser.getQuery(QParser.java:142)
> at org.apache.solr.search.QueryParsing.parseSort(QueryParsing.java:271)
> ... 22 more
> 
> 
> I would like to sort by distance and also to return that distance as a fl
> parameter inside the response.
> 
> Thank you very much.
> 
> Regards,
> 
> 
> - Luis Cappa
> 
> 
> 2013/3/5 Chris Hostetter &lt;

> hossman_lucene@

> &gt;
> 
>>
>> 1) which version of solr are you using?
>> 2) what is the field & fieldtype for "geolocation"
>> 2) can you try changing your query to "q={!func}geodist()" to verify that
>> the function works at all?
>>
>>
>>
>> : Date: Tue, 5 Mar 2013 19:30:33 +0100
>> : From: Luis Cappa Banda &lt;

> luiscappa@

> &gt;
>> : Reply-To: 

> solr-user@.apache

>> : To: 

> solr-user@.apache

>> : Subject: Re: Solr 4.1: problems with Spatial Search.
>> :
>> : Without the sort it works perfectly, and there are no more error
>> messages,
>> : just the one I copy&pasted, :-(
>> : El 05/03/2013 19:05, "David Smiley (@MITRE.org)" &lt;

> DSMILEY@

> &gt;
>> : escribió:
>> :
>> : > Hmm; weird.  It looks right.  Does it work without the sort? -- i.e.
>> does
>> : > the
>> : > filter work?  Are there more interesting looking error messages
>> output
>> by
>> : > Solr?
>> : >
>> : >
>> : > Rakudten wrote
>> : > > Hello!
>> : > >
>> : > > I´m trying to sort by geodist() distance, but it seems that I
>> can´t:
>> : > >
>> : > > *The query:*
>> : > >
>> : > >
>> : >
>> http://192.168.1.129:8080/geo/zones/select?q=*:*&fq={!geofilt}&sfield=geolocation&pt=38.96442,-3.89047&d=10&wt=json&start=0&rows=10&sort=geodist()%20asc
>> : > >
>> : > > *The response:*
>> : > > *
>> : > > *
>> : > >
>> : > > {
>> : > > responseHeader: {
>> : > > status: 400,
>> : > > QTime: 2,
>> : > > params: {
>> : > > d: "10",
>> : > > sort: "geodist() asc",
>> : > > start: "0",
>> : > > q: "*:*",
>> : > > sfield: "geolocation",
>> : > > pt: "38.96442,-3.89047",
>> : > > wt: "json",
>> : > > fq: "{!geofilt}",
>> : > > rows: "10"
>> : > > }
>> : > > },
>> : > > error: {
>> : > > msg: "sort param could not be parsed as a query, and is not a field
>> that
>> : > > exists in the index: geodist()",
>> : > > code: 400
>> : > > }
>> : > > }
>> : > >
>> : > > I´ve read several times the documentation and it seems that this is
>> the
>> : > > correct way to search filtering by coordinates and sorting by
>> distance,
>> : > > but
>> : > > I doesn´t work. Any suggestions?
>> : > >
>> : > > Also I´ve tried to return the distance as a field via fl params,
>> but
>> I
>> : > > couldn´t. It may help me a lot if anyone could tell me how to do
>> it.
>> : > >
>> : > > Thank you very much in advance!
>> : > >
>> : > >
>> : > > Best regards,
>> : > >
>> : > >
>> : > > - Luis Cappa
>> : >
>> : >
>> : >
>> : >
>> : >
>> : > -----
>> : >  Author:
>> : > http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
>> : > --
>> : > View this message in context:
>> : >
>> http://lucene.472066.n3.nabble.com/Solr-4-1-problems-with-Spatial-Search-tp4044868p4044958.html
>> : > Sent from the Solr - User mailing list archive at Nabble.com.
>> : >
>> :
>>
>> -Hoss





-----
 Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/Solr-4-1-problems-with-Spatial-Search-tp4044868p4045231.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message