You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ziqi Zhang <zi...@sheffield.ac.uk> on 2015/09/17 17:14:28 UTC

how to write this SOLR query in LUCENE api?

Hi

I am using the TermsComponent in my solr config like this to deal with 
queries about terms in the index:

--------------
<searchComponent name="terms" class="solr.TermsComponent"/>

   <!-- A request handler for demonstrating the terms component -->
   <requestHandler name="/terms" class="solr.SearchHandler" startup="lazy">
      <lst name="defaults">
       <bool name="terms">true</bool>
       <bool name="distrib">false</bool>
     </lst>
     <arr name="components">
       <str>terms</str>
     </arr>
   </requestHandler>
-----------


For example, I want to fetch any *terms* containing "surface defects". 
Using solr I can do this:

http://localhost:8983/solr/core1/terms?terms.fl=content&terms.regex=^(.*?(\bsurface%20defects\b)[^$]*)$&terms.sort=count&terms.limit=10000


So my question is, how can I achieve the same by using the Lucene API, 
not solr? I looked into the 
org.apache.solr.handler.component.TermsComponent class but it is not 
very obvious for me.

Any suggestions much appreciated!


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: how to write this SOLR query in LUCENE api?

Posted by Trejkaz <tr...@trypticon.org>.
On Fri, Sep 18, 2015 at 1:14 AM, Ziqi Zhang <zi...@sheffield.ac.uk> wrote:
=>
> So my question is, how can I achieve the same by using the Lucene API, not
> solr? I looked into the org.apache.solr.handler.component.TermsComponent
> class but it is not very obvious for me.

org.apache.lucene.search.RegexpQuery.

Or, if your regexes are not trivial enough to be represented by that
one, org.apache.lucene.sandbox.queries.regex.RegexQuery.

TX

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org