Return-Path: X-Original-To: apmail-lucene-solr-user-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 972DAE619 for ; Wed, 6 Mar 2013 14:49:00 +0000 (UTC) Received: (qmail 32928 invoked by uid 500); 6 Mar 2013 14:48:56 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 32617 invoked by uid 500); 6 Mar 2013 14:48:56 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 32571 invoked by uid 99); 6 Mar 2013 14:48:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Mar 2013 14:48:54 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=NORMAL_HTTP_TO_IP,SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Mar 2013 14:48:49 +0000 Received: from ben.nabble.com ([192.168.236.152]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1UDFdr-000758-Rj for solr-user@lucene.apache.org; Wed, 06 Mar 2013 06:48:27 -0800 Date: Wed, 6 Mar 2013 06:48:27 -0800 (PST) From: "David Smiley (@MITRE.org)" To: solr-user@lucene.apache.org Message-ID: <1362581307849-4045231.post@n3.nabble.com> In-Reply-To: References: <1362506690391-4044958.post@n3.nabble.com> Subject: Re: Solr 4.1: problems with Spatial Search. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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_Relev= ancy And you'll see an example query along the lines of what you want: &fl=3D*,score&sort=3Dscore asc&q=3D{! score=3Ddistance}geo:"Intersects(Circle(54.729696,-98.525391 d=3D10))"=20 (the score is the distance in this case) ~ David Rakudten wrote > Hello everyone! >=20 > - I=C2=B4m using Solr 4.1.0. >=20 >=20 > - Yes, without the sort the query works perfectly. >=20 >=20 > - The fieldType is as follows: >=20 > =20 > stored=3D"true" multiValued=3D"true" /> > * * > =20 > class=3D"solr.SpatialRecursivePrefixTreeFieldType" >=20 >=20 > spatialContextFactory=3D"com.spatial4j.core.context.jts.JtsSpatialContext= Factory" > distErrPct=3D"0.025" > maxDistErr=3D"0.000009" > units=3D"degrees" > /> > - The error trace from Solr: >=20 > 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.j= ava:123) > at > org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchH= andler.java:187) > at > org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBa= se.java:135) > at org.apache.solr.core.SolrCore.execute(SolrCore.java:1816) > at > org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.jav= a:448) > at > org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.ja= va:269) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat= ionFilterChain.java:243) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte= rChain.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.j= ava:118) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:40= 7) > at > org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Pr= ocessor.java:1001) > at > org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Abst= ractProtocol.java:585) > at > org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.ja= va:312) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor= .java:886) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.jav= a: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 distanc= e > as the score. > at > org.apache.solr.schema.AbstractSpatialFieldType.getValueSource(AbstractSp= atialFieldType.java:219) > at > org.apache.solr.search.function.distance.HaversineConstFunction.parseSfie= ld(HaversineConstFunction.java:168) > at > org.apache.solr.search.function.distance.HaversineConstFunction.access$20= 0(HaversineConstFunction.java:47) > at > org.apache.solr.search.function.distance.HaversineConstFunction$1.parse(H= aversineConstFunction.java:104) > at > org.apache.solr.search.FunctionQParser.parseValueSource(FunctionQParser.j= ava: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 >=20 >=20 > I would like to sort by distance and also to return that distance as a fl > parameter inside the response. >=20 > Thank you very much. >=20 > Regards, >=20 >=20 > - Luis Cappa >=20 >=20 > 2013/3/5 Chris Hostetter < > hossman_lucene@ > > >=20 >> >> 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=3D{!func}geodist()" to verify t= hat >> the function works at all? >> >> >> >> : Date: Tue, 5 Mar 2013 19:30:33 +0100 >> : From: Luis Cappa Banda < > luiscappa@ > > >> : Reply-To:=20 > solr-user@.apache >> : To:=20 > 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)" < > DSMILEY@ > > >> : escribi=C3=B3: >> : >> : > 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=C2=B4m trying to sort by geodist() distance, but it seems that I >> can=C2=B4t: >> : > > >> : > > *The query:* >> : > > >> : > > >> : > >> http://192.168.1.129:8080/geo/zones/select?q=3D*:*&fq=3D{!geofilt}&sfiel= d=3Dgeolocation&pt=3D38.96442,-3.89047&d=3D10&wt=3Djson&start=3D0&rows=3D10= &sort=3Dgeodist()%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 fiel= d >> that >> : > > exists in the index: geodist()", >> : > > code: 400 >> : > > } >> : > > } >> : > > >> : > > I=C2=B4ve read several times the documentation and it seems that t= his is >> the >> : > > correct way to search filtering by coordinates and sorting by >> distance, >> : > > but >> : > > I doesn=C2=B4t work. Any suggestions? >> : > > >> : > > Also I=C2=B4ve tried to return the distance as a field via fl para= ms, >> but >> I >> : > > couldn=C2=B4t. 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/boo= k -- View this message in context: http://lucene.472066.n3.nabble.com/Solr-4-1-p= roblems-with-Spatial-Search-tp4044868p4045231.html Sent from the Solr - User mailing list archive at Nabble.com.