You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by gnandre <ar...@gmail.com> on 2020/05/30 04:32:06 UTC

Lucene query to Solr query

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.

Re: Lucene query to Solr query

Posted by gnandre <ar...@gmail.com>.
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 <mk...@apache.org> 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 <ar...@gmail.com> 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 <er...@gmail.com>
> > 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 <ar...@gmail.com>
> 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
>

Re: Lucene query to Solr query

Posted by Mikhail Khludnev <mk...@apache.org>.
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 <ar...@gmail.com> 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 <er...@gmail.com>
> 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 <ar...@gmail.com> 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

Re: Lucene query to Solr query

Posted by gnandre <ar...@gmail.com>.
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 <er...@gmail.com>
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 <ar...@gmail.com> 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.
>
>

Re: Lucene query to Solr query

Posted by Erick Erickson <er...@gmail.com>.
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 <ar...@gmail.com> 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.