Giter Site home page Giter Site logo

Facet Query about bobobrowse.net HOT 2 CLOSED

nightowl888 avatar nightowl888 commented on July 29, 2024
Facet Query

from bobobrowse.net.

Comments (2)

NightOwl888 avatar NightOwl888 commented on July 29, 2024

Upon researching this, I discovered that there was a bug in the ToString() method in that it wasn't correctly returning the results of the facets, which will be addressed in the next release.

The results of the 2 queries are returning the exact same documents in the same order.

However, Lucene.Net uses a different scoring strategy than the default scoring of BoboBrowse.Net so the scores are different. If you look at the [Facet Scoring](https://linkedin.jira.com/wiki/display/BOBO/Facet+Query#FacetQuery-Scoring page) section, you can see that the score can be customized. So, I am not considering this a bug - it looks like this is normal behavior as the scores are defaulting to 1*boost and the score can be customized further if need be. Besides, scores are relative numbers, not absolute numbers and their relative values are correct. And there are quite a few tests covering this scenario that are all passing (TestFacetQueryBoost, TestFacetQuery, TestFacetQueryBoolean, TestFacetRangeQuery).

Comparing the output of ToString() is not a good way to determine if the 2 results are the same. In the Lucene.Net case there are no facets being returned and as previously mentioned the scores are different. The score could be fixed by building a custom scoring function, and the facets will be included if you add a FacetSpec as shown below, but you are better off comparing the individual values to ensure they appear in the same order and quantities.

// Bobo.
{
    BrowseRequest browseRequest = new BrowseRequest();
    browseRequest.Count = 10;
    browseRequest.Offset = 0;
    browseRequest.FetchStoredFields = true;

    BrowseSelection sel = new BrowseSelection(field);
    sel.Values = new string[] { v1, v2, v3 };
    browseRequest.AddSelection(sel);

    Dictionary<string, float> boostMap = new Dictionary<string, float>();
    boostMap.Add(v1, b1);
    boostMap.Add(v2, b2);
    boostMap.Add(v3, b3);

    // Add a custom scoring function factory that has the same scoring logic as Lucene.Net
    BoboBrowse.Net.Query.Scoring.IFacetTermScoringFunctionFactory scoringFunctionFactory = CustomScoringFunctionFactory();

    BoboBrowse.Net.Query.Scoring.FacetTermQuery resultQ = new BoboBrowse.Net.Query.Scoring.FacetTermQuery(sel, boostMap, scoringFunctionFactory);
    browseRequest.Query = resultQ;

    FacetSpec spec = new FacetSpec();
    spec.MaxCount = 10;
    browseRequest.SetFacetSpec(field, spec);

    IBrowsable browser = new BoboBrowser(boboReader);
    result = browser.Browse(browseRequest);

    totalHits = result.NumHits;
}

// Lucene.
{
    BrowseRequest browseRequest = new BrowseRequest();
    browseRequest.Count = 10;
    browseRequest.Offset = 0;
    browseRequest.FetchStoredFields = true;

    BooleanQuery resultQ = new BooleanQuery();

    TermQuery tq = new TermQuery(new Term(field, v1));
    tq.Boost = b1;
    resultQ.Add(tq, Occur.SHOULD);

    tq = new TermQuery(new Term(field, v2));
    tq.Boost = b2;
    resultQ.Add(tq, Occur.SHOULD);

    tq = new TermQuery(new Term(field, v3));
    tq.Boost = b3;
    resultQ.Add(tq, Occur.SHOULD);

    browseRequest.Query = resultQ;

        // If you includ a FacetSpec, the facets will be ruturned
    FacetSpec spec = new FacetSpec();
    spec.MaxCount = 10;
    browseRequest.SetFacetSpec(field, spec);

    IBrowsable browser = new BoboBrowser(boboReader);
    result2 = browser.Browse(browseRequest);

    totalHits2 = result.NumHits;
}

from bobobrowse.net.

NightOwl888 avatar NightOwl888 commented on July 29, 2024

Closing this issue as a wontfix. As I mentioned, ToString should not be relied upon for testing purposes. It is there for informational/debugging purposes only. That said, there were several ToString fixes in the latest release, 3.2.2.

from bobobrowse.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.