Solr DisMax and 'New' DateField query syntax

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Solr DisMax and 'New' DateField query syntax

Dan Davis
First off, solr has done nothing but wonders for me! So let me give everyone envolved a big cheers!

Recently I discovered the 'new' DateField syntax options which allow "[NOW/DAY-1MONTH]" type querys. However when going to try out this I found a possible bug (or maybe I'm just missing something) when using it in junction with the DisMaxRequestHandler. Can anyone point me in the right direction or confirm it's a bug for me. Below is the error.

Currently I'm speficing a fq query like so:

fq=timestamp:[NOW/DAY-1MONTH]

Here is the error I get:

org.apache.lucene.queryParser.ParseException: Cannot parse 'timestamp:[NOW/DAY-1MONTH]': Encountered "]" at line 1, column 25. Was expecting one of: "TO" ... ... ... at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:127) at org.apache.solr.request.SimpleFacets.getFacetQueryCounts(SimpleFacets.java:112) at org.apache.solr.request.SimpleFacets.getFacetCounts(SimpleFacets.java:81) at org.apache.solr.request.DisMaxRequestHandler.getFacetInfo(DisMaxRequestHandler.java:416) at org.apache.solr.request.DisMaxRequestHandler.handleRequest(DisMaxRequestHandler.java:342) at org.apache.solr.core.SolrCore.execute(SolrCore.java:595) at org.apache.solr.servlet.SolrServlet.doGet(SolrServlet.java:92) at org.apache.solr.servlet.SolrServlet.doPost(SolrServlet.java:83) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595)

Thanks,
Dan
Reply | Threaded
Open this post in threaded view
|

Re: Solr DisMax and 'New' DateField query syntax

Chris Hostetter-3

the square brackets raen't anything new ... they are the standard Lucene
QUeryParser syntax for range queries, which have hte syntax...
        field:[low TO high]

in conjuntion with the new DateMath, you need something along the lines
of...
        timestamp:[NOW/DAY-1MONTH TO NOW/DAY+1DAY]

...assuming your goal is to find timestamps in the past month.

i used NOW/DAY+1DAY as the upper bound instead of NOW so it will have the
same day granularity as the lower bound (good for caching) and won't miss
things added today.

: Recently I discovered the 'new' DateField syntax options which allow
: "[NOW/DAY-1MONTH]" type querys. However when going to try out this I found a
: possible bug (or maybe I'm just missing something) when using it in junction
: with the DisMaxRequestHandler. Can anyone point me in the right direction or
: confirm it's a bug for me. Below is the error.
:
: Currently I'm speficing a fq query like so:
:
: fq=timestamp:[NOW/DAY-1MONTH]





-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: Solr DisMax and 'New' DateField query syntax

Dan Davis
Duuh! Stupid me. I didn't even try that. Thanks for such a quick replay. That should solve my problem..Thanks Hoss!!

Chris Hostetter wrote
the square brackets raen't anything new ... they are the standard Lucene
QUeryParser syntax for range queries, which have hte syntax...
        field:[low TO high]

in conjuntion with the new DateMath, you need something along the lines
of...
        timestamp:[NOW/DAY-1MONTH TO NOW/DAY+1DAY]

...assuming your goal is to find timestamps in the past month.

i used NOW/DAY+1DAY as the upper bound instead of NOW so it will have the
same day granularity as the lower bound (good for caching) and won't miss
things added today.

: Recently I discovered the 'new' DateField syntax options which allow
: "[NOW/DAY-1MONTH]" type querys. However when going to try out this I found a
: possible bug (or maybe I'm just missing something) when using it in junction
: with the DisMaxRequestHandler. Can anyone point me in the right direction or
: confirm it's a bug for me. Below is the error.
:
: Currently I'm speficing a fq query like so:
:
: fq=timestamp:[NOW/DAY-1MONTH]





-Hoss
Reply | Threaded
Open this post in threaded view
|

Multiple entries in a field

Stefano Nicolai
In reply to this post by Dan Davis
Hi all.
I'm trying Solr for the first time, and i find it simply amazing, cheers
to the developers!

While i was writing down the XML creator file, i came up with a
question: i work for an online shop, and we sell books.
This particular product can have multiple authors / translators in its
"author" / "translators" fields.

I want a single <field name="author"....> for a better indexer, instead
of making something like <field name="author_1"|"author_2"  ... > as
some books have a single entry.

I'm worried that simply pushing into this field the infos related to the
authors (i.e. "Stephen Rich" and "Karl King") it could give bad answers
to my queries (i.e. returning "Stephen King" as a positive match),
basically mixing up the words it finds inside.

Is there a way to solve this problem? Are the words tokenized with some
sort of relation?


I came up with 3 ideas, but i'd love to hear something from you, as none
of them seems the right one.

1) I can push inside that field something like ("name1 surname1"
"surname1 name1" "name2 surname2" "surname2 name2" "name1" "name2"
"surname1" "surname2") to match all the possible cases, and "force" the
query to look first at the strings inside, but somehow i think this goes
against the main idea behind this project.

2) Making 2 fields, one for "author_name, author_surname" and one for
the single words to allow single word match.

3) Placing a " , " separator between the words, to enforce the relation,
makind a sort of multiple field.


Thanks for your time.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple entries in a field

Yonik Seeley-2
On 2/20/07, Stefano Nicolai <[hidden email]> wrote:
> I'm worried that simply pushing into this field the infos related to the
> authors (i.e. "Stephen Rich" and "Karl King") it could give bad answers
> to my queries (i.e. returning "Stephen King" as a positive match),
> basically mixing up the words it finds inside.
>
> Is there a way to solve this problem? Are the words tokenized with some
> sort of relation?

Token positions are indexed by default, so one needs to use a query
type that takes position into account (like phrase or sloppy phrase
queries).

http://lucene.apache.org/java/docs/queryparsersyntax.html

The tokens from multiple values for a field to get indexed "together",
but there is a configurable positionIncrement to help separate the
values.  This can prevent matching across different values in a sloppy
phrase query.

-Yonik