basho / riak-nodejs-client

The Riak client for Node.js.
Apache License 2.0
72 stars 28 forks source link

yokozuna filterQuery problem [JIRA: CLIENTS-831] #153

Open zhaohanweng opened 8 years ago

zhaohanweng commented 8 years ago

When I call

http://localhost:8098/search/query/solr-index?wt=json&q=*:*&fq={!geofilt pt=43.76190533278233,-79.408447073731 sfield=onboardingCoords d=0.01} 

This works.

But If I use the nodejs client, and pass in filterQuery in the search,

riak.search({
    indexName: 'solr-index',
    q: '*:*',
    filterQuery: "{!geofilt pt=43.76190533278233,-79.408447073731 sfield=onboardingCoords d=0.1}"
})

I got the following error.

 <0.23930.3>@yz_pb_search:maybe_process:111 {solr_error,{500,"http://localhost:8093/internal_solr/solr-index/select",<<"{\"error\":{\"msg\":\"The field onboardingCoords does not support spatial filtering\",\"trace\":\"org.apache.solr.common.SolrException: The field onboardingCoords does not support spatial filtering\\n\\tat org.apache.solr.search.SpatialFilterQParser.parse(SpatialFilterQParser.java:84)\\n\\tat org.apache.solr.search.QParser.getQuery(QParser.java:141)\\n\\tat org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:168)\\n\\tat org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:193)\\n\\tat org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)\\n\\tat org.apache.solr.core.SolrCore.execute(SolrCore.java:1916)\\n\\tat org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:780)\\n\\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:427)\\n\\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:217)\\n\\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)\\n\\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)\\n\\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)\\n\\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)\\n\\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)\\n\\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)\\n\\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)\\n\\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)\\n\\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)\\n\\tat org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)\\n\\tat org.eclipse.jetty.server.handler.HandlerCollecti...">>}} [{yz_solr,search,3,[{file,"src/yz_solr.erl"},{line,292}]},{yz_pb_search,maybe_process,3,[{file,"src/yz_pb_search.erl"},{line,76}]},{riak_api_pb_server,process_message,4,[{file,"src/riak_api_pb_server.erl"},{line,388}]},{riak_api_pb_server,connected,2,[{file,"src/riak_api_pb_server.erl"},{line,226}]},{riak_api_pb_server,decode_buffer,2,[{file,"src/riak_api_pb_server.erl"},{line,364}]},{gen_fsm,handle_msg,7,[{file,"gen_fsm.erl"},{line,505}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]

Is the filterQuery the same as fq ? If not how can I pass in fq using nodejs client.

Here's my schema:

<schema>
    <fields>
        <field name="onboardingCoords" type="location" indexed="true" stored="true" multiValued="false"/>
        <dynamicField name="*_coordinate"  type="tdouble" indexed="true"  stored="false"/>
    </fields>

        .......

    <types>
        <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>

        <!-- A specialized field for geospatial search. If indexed, this fieldType must not be multivalued. -->
        <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
    </types>
</schema>
lukebakken commented 8 years ago

@zeeshanlakhani - I don't believe the current PB message for a YZ search allows this, does it?

zeeshanlakhani commented 8 years ago

@lukebakken due to backwards compat reasons, it's called filter -> https://github.com/basho/yokozuna/blob/dbdaaaf6767cd3bf01b982f36ef8325af505cafa/src/yz_pb_search.erl#L135.

lukebakken commented 8 years ago

@zeeshanlakhani - thanks. In the user's example, filterQuery is passed via the filter PB message field (here), yet he's getting those results (?)

lukebakken commented 8 years ago

@zhaohanweng - could you please provide sample data so I can try to reproduce this issue?

zhaohanweng commented 8 years ago

Hi, thank you for the comments, I just figured that I can just pass {!geofilt pt=43.76190533278233,-79.408447073731 sfield=onboardingCoords d=0.1} in q instead of fq and everything works now.

But the error with fq should still be resolved.

Sorry I dont have any sample data. To reproduce this, only need "lat, long" data in a location field, and index it.

lukebakken commented 8 years ago

@zhaohanweng - thanks for letting us know.