Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-9664

Allow non-text columns to influence the text search score for sorting

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Text Search
    • Labels:
      None

      Description

      Allow for specifying weights on a non-text field, to be included in the 'score' of text-search. Example input and output:

      > db.dropDatabase()
      { "dropped" : "banana", "ok" : 1 }
      > use banana
      switched to db banana
      > db.c.insert({title: 'How to dress a chicken', popularity: 10});
      > db.c.insert({title: 'Keeping chickens cooped up', popularity: 4});
      > db.c.insert({title: 'Chicken soup for the left foot', popularity: 15});
      > db.c.ensureIndex({'title':'text', popularity: 1}, {weights: { title: 1, popularity: 10} });
      > db.runCommand({text:'c', search:'chicken'});

      Ideally it would assume that non-text based columns are always 100% match. Some multiplication of the specified weight with the value of the non-text field would then be combined with the text-field weight to create the final answer. The actual method of combining them is likely quite flexible as the user could adjust the popularity base value and weights as needed.

      As a rough example:
      finalScore = rawScore + popularityWeight * popularity;

      (Clearly this would need to be refined as more usage data is collected. This would simply provide a deterministic means to add arbitrary sorting to the results.)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated: