n-gramvespa

search Chain not getting accepted in vespa


I am trying to add a searcher code in my java/ai/vespa/example path. The searcher code basically changes the Ngram Searcher from AND to OR. I added this searcher code path reference to services.xml

<search>
        <chain id='ORgram' inherits='vespa' 
excludes='com.yahoo.search.querytransform.NGramSearcher'>
        <searcher bundle='gram-searcher' id='ai.vespa.examples.OrNGramSearcher'/>
        </chain>
    </search>

But, when I am trying to add this searchChain to my query it is giving me an error.

 **'message': "No search chain named 'ORgram' was found"**

Neither the NGram Searcher is getting excluded from the results nor the new OR gram searcher is being applied to it.

The searcher code is:-

package ai.vespa.example;

import com.yahoo.search.Query;
import com.yahoo.prelude.query.CompositeItem;
import com.yahoo.prelude.query.OrItem;
import com.yahoo.prelude.query.HasIndexItem;
import com.yahoo.search.querytransform.NGramSearcher;
import com.yahoo.language.Linguistics;

public class OrNGramSearcher extends NGramSearcher {

    public OrNGramSearcher(Linguistics linguistics) {
        super(linguistics);
    }

    @Override
    protected CompositeItem createGramRoot(HasIndexItem term, Query query) {
        return new OrItem();
    }

}

Other than that I am also following the maven layout which has pom.xml and the bundle id which I am using in the services.xml for is the same as the artifactID in the pom.xml.


Solution

  • Make sure you run

    mvn install
    

    before

    vespa deploy
    

    to build the new application package.