Lucene query to Solr query

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

Lucene query to Solr query

gnandre
Hi,

I have following query which works fine as a lucene query:
+(topics:132)^0.02607211 (topics:146)^0.008187325
-asset_id:doc:en:index.html

But, it does not work if I use it as a solr query with lucene as defType.

For it to work, I need to convert it like following:
q=+((topics:132)^0.02607211 (topics:146)^0.008187325
+(-(asset_id:doc\:en\:index.html))&defType=edismax&q.op=OR

Why does it not work as is? AFAIK syntax given in the first query is
supported by edismax.
Reply | Threaded
Open this post in threaded view
|

Re: Lucene query to Solr query

Erick Erickson
edismas is quite different from straight Lucene.

Try attaching &debug=query to the input and
you’ll see the difference.

Best,
Erick

> On May 30, 2020, at 12:32 AM, gnandre <[hidden email]> wrote:
>
> Hi,
>
> I have following query which works fine as a lucene query:
> +(topics:132)^0.02607211 (topics:146)^0.008187325
> -asset_id:doc:en:index.html
>
> But, it does not work if I use it as a solr query with lucene as defType.
>
> For it to work, I need to convert it like following:
> q=+((topics:132)^0.02607211 (topics:146)^0.008187325
> +(-(asset_id:doc\:en\:index.html))&defType=edismax&q.op=OR
>
> Why does it not work as is? AFAIK syntax given in the first query is
> supported by edismax.

Reply | Threaded
Open this post in threaded view
|

Re: Lucene query to Solr query

gnandre
I think this question here in this thread is similar to my question.
https://lucene.472066.n3.nabble.com/Lucene-Query-to-Solr-query-td493751.html


As suggested in that thread, I do not want to use toString method for
Lucene query to pass it to the q param in SolrQuery.

I am looking for a function that accepts org.apache.lucene.search.Query and
returns org.apache.solr.client.solrj.SolrQuery. Is that possible?

On Sat, May 30, 2020 at 8:08 AM Erick Erickson <[hidden email]>
wrote:

> edismas is quite different from straight Lucene.
>
> Try attaching &debug=query to the input and
> you’ll see the difference.
>
> Best,
> Erick
>
> > On May 30, 2020, at 12:32 AM, gnandre <[hidden email]> wrote:
> >
> > Hi,
> >
> > I have following query which works fine as a lucene query:
> > +(topics:132)^0.02607211 (topics:146)^0.008187325
> > -asset_id:doc:en:index.html
> >
> > But, it does not work if I use it as a solr query with lucene as defType.
> >
> > For it to work, I need to convert it like following:
> > q=+((topics:132)^0.02607211 (topics:146)^0.008187325
> > +(-(asset_id:doc\:en\:index.html))&defType=edismax&q.op=OR
> >
> > Why does it not work as is? AFAIK syntax given in the first query is
> > supported by edismax.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Lucene query to Solr query

Mikhail Khludnev-2
There's nothing like this now. Presumably one might visit queries and
generate Query DSL json, but it might be a challenging problem.

On Sun, May 31, 2020 at 3:42 AM gnandre <[hidden email]> wrote:

> I think this question here in this thread is similar to my question.
>
> https://lucene.472066.n3.nabble.com/Lucene-Query-to-Solr-query-td493751.html
>
>
> As suggested in that thread, I do not want to use toString method for
> Lucene query to pass it to the q param in SolrQuery.
>
> I am looking for a function that accepts org.apache.lucene.search.Query and
> returns org.apache.solr.client.solrj.SolrQuery. Is that possible?
>
> On Sat, May 30, 2020 at 8:08 AM Erick Erickson <[hidden email]>
> wrote:
>
> > edismas is quite different from straight Lucene.
> >
> > Try attaching &debug=query to the input and
> > you’ll see the difference.
> >
> > Best,
> > Erick
> >
> > > On May 30, 2020, at 12:32 AM, gnandre <[hidden email]> wrote:
> > >
> > > Hi,
> > >
> > > I have following query which works fine as a lucene query:
> > > +(topics:132)^0.02607211 (topics:146)^0.008187325
> > > -asset_id:doc:en:index.html
> > >
> > > But, it does not work if I use it as a solr query with lucene as
> defType.
> > >
> > > For it to work, I need to convert it like following:
> > > q=+((topics:132)^0.02607211 (topics:146)^0.008187325
> > > +(-(asset_id:doc\:en\:index.html))&defType=edismax&q.op=OR
> > >
> > > Why does it not work as is? AFAIK syntax given in the first query is
> > > supported by edismax.
> >
> >
>


--
Sincerely yours
Mikhail Khludnev
Reply | Threaded
Open this post in threaded view
|

Re: Lucene query to Solr query

gnandre
Is this odd use-case where one needs to convert Lucene query to Solr query?
Isn't this normal use-case when somebody is trying to port their Lucene
code to Solr?
I mean, is it like a XY problem where I should not even run into this
problem in the first place?


On Sun, May 31, 2020 at 9:40 AM Mikhail Khludnev <[hidden email]> wrote:

> There's nothing like this now. Presumably one might visit queries and
> generate Query DSL json, but it might be a challenging problem.
>
> On Sun, May 31, 2020 at 3:42 AM gnandre <[hidden email]> wrote:
>
> > I think this question here in this thread is similar to my question.
> >
> >
> https://lucene.472066.n3.nabble.com/Lucene-Query-to-Solr-query-td493751.html
> >
> >
> > As suggested in that thread, I do not want to use toString method for
> > Lucene query to pass it to the q param in SolrQuery.
> >
> > I am looking for a function that accepts org.apache.lucene.search.Query
> and
> > returns org.apache.solr.client.solrj.SolrQuery. Is that possible?
> >
> > On Sat, May 30, 2020 at 8:08 AM Erick Erickson <[hidden email]>
> > wrote:
> >
> > > edismas is quite different from straight Lucene.
> > >
> > > Try attaching &debug=query to the input and
> > > you’ll see the difference.
> > >
> > > Best,
> > > Erick
> > >
> > > > On May 30, 2020, at 12:32 AM, gnandre <[hidden email]>
> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I have following query which works fine as a lucene query:
> > > > +(topics:132)^0.02607211 (topics:146)^0.008187325
> > > > -asset_id:doc:en:index.html
> > > >
> > > > But, it does not work if I use it as a solr query with lucene as
> > defType.
> > > >
> > > > For it to work, I need to convert it like following:
> > > > q=+((topics:132)^0.02607211 (topics:146)^0.008187325
> > > > +(-(asset_id:doc\:en\:index.html))&defType=edismax&q.op=OR
> > > >
> > > > Why does it not work as is? AFAIK syntax given in the first query is
> > > > supported by edismax.
> > >
> > >
> >
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>