solredismaxdismax

how to use pf(Phrase Fields) and ps(Phrase Slop) of eDisMax Query Parser in solr?


What is Phrase Fields, Phrase Slop and Query Phrase Slop in eDisMax. I go through many website but not understand these with implementation. I want to know how query pass in solr using this and how output differs from each other If I have following data.

{
   "id":"2",
   "shipping_firstname":"Sudhanshu",
   "address":"H.No. 444, Gali No.2 Jain Nagar",
   "date_added":"2017-01-21T14:15:15Z",
   "_version_":1562029999829024768}]
}

Solution

  • Welcome,

    Phrase Fields, Phrase Slop and Query Phrase Slop in eDisMax parser are used to boost a document based on certain criteria.

    Based on your use case you can give different boost values to manipulate the overall score of a document.

    The pf (Phrase Fields) parameter can be used to boost the score of documents in which all of the terms in the q parameter appear in close proximity. The pf parameter takes a list of fields and optional corresponding boosts. The eDisMax query parser will attempt to make phrase queries out of all the terms in the q parameter, and if it’s able to find the exact phrase in any of the phrase fields, it will apply the specified boost to the match for that document.

    The ps (Phrase Slop) parameter :

    When using the pf parameter, you may not want to require all terms in the query to appear as an exact phrase. You can make use of the ps (phrase slop) parameter to specify how many term positions the terms in the query can be off by to be considered a match on the phrase fields.

    The qs (Query Phrase Slop) parameter :

    Just as the ps parameter allows you to define the amount of slop (edit distances) on phrases matching in the phrase fields (pf parameter), the qs parameter allows you to do the same for phrases the user explicitly specifies in the main q parameter. Think of the qs parameter as redefining what an exact match is, allowing you to change the slop from the default of 0 (terms must appear beside each other) to a higher number.

    What is your requirement here? These params can only help you for ranking results to boost or get some documents at the top and not in actual search criteria or finding matching documents.