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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Text Search
    • Labels:
    • Query Integration

      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.)

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            wshaver Will Shaver
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: