Skip to content

Get me up and running

Andrea Gazzarini edited this page May 2, 2018 · 9 revisions

Get the plugin library

Get the jar file in one of the following ways:

Download

https://github.com/SeaseLtd/solr-quantities-detection-qparsers/raw/mvn-repo/com/spaziocodice/labs/solr-quantities-detection-qparsers/1.0/solr-quantities-detection-qparsers-1.0.jar

Through Maven

<repositories>
    <repository>
        <id>solr-quantities-detection-qparsers-mvn-repo</id>
        <url>https://raw.github.com/SeaseLtd/solr-quantities-detection-qparsers/mvn-repo/</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

...

<dependency>
    <groupId>io.sease</groupId>
    <artifactId>solr-quantities-detection-qparsers</artifactId>
    <version>1.0</version>
</dependency>

Build from source

Assuming you already have Java 8 and Apache Maven (3.x) in your environment, just clone this repository and then run

$ mvn clean install

At the end the artifact solr-quantities-detection-qparsers-1.0.jar will be built under the target folder

Create the configuration

The module configuration is detailed here, you can grab some additional example under the test/resources directory [1] of the project.

Once created, the file units.json must be put under the core conf directory.

Solr configuration

The configuration, within the solrconfig.xml, in places.

lib location

You have several alternatives here:

  • put the plugin library under the lib folder
  • use the <lib directive in solrconfig.xml

If you are on the development machine and you downloaded the library as a Maven dependency, you can put this line in the solrconfig.xml:

<lib dir="${user.home}/.m2/repository/io/sease/labs/solr-quantities-detection-qparsers/1.0/" regex=".*\.jar" />

It will grab the dependency in your local repository.

QParserPlugin

The repository contains three plugins:

<queryParser name="qty" class="io.sease.labs.solr.qty.QuantityDetectionQParserPlugin"/>
<queryParser name="bqty" class="io.sease.labs.solr.qty.QuantityDetectionBQParserPlugin"/>
<queryParser name="bfqty" class="io.sease.labs.solr.qty.QuantityDetectionBFParserPlugin"/>   

In the example above:

  • qty is the name of the QParserPlugin which produces the parser for analysing the main query (q)
  • bqty is the name of the QParserPlugin which produces the parser for analysing boost queries (bq)
  • bfqty is the name of the QParserPlugin which produces the parser for analyzing boost functions (bf)

you use a different name for them, of course. But if you do that, remember that those names will be used in the subsequent configuration section.

RequestHandler

The following is just an example: the actual configuration depends on your context. Note the QParserPlugin identifiers defined in the previous section must be the same.

    <requestHandler name="/search" class="solr.SearchHandler" default="true">
        <lst name="invariants">
            <str name="defType">qty</str>
        </lst>
        <lst name="defaults">
            <str name="qf">
                product_name
                brand
            </str>
            <str name="bq">{!bqty v=$q}</str>
            <str name="boost">{!bfqty v=$q}</str>
        </lst>
    </requestHandler>

And that should be all what you need. Enjoy!


[1] https://github.com/SeaseLtd/solr-quantities-detection-qparsers/tree/master/src/test/resources

Clone this wiki locally