Solr
  1. Solr
  2. SOLR-117

constrain field faceting to a prefix

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2
    • Component/s: search
    • Labels:
      None

      Description

      Useful for faceting as someone is typing, autocompletion, etc

      1. facet_prefix.patch
        21 kB
        Yonik Seeley
      2. facet_prefix.patch
        2 kB
        Yonik Seeley

        Activity

        Hide
        Yonik Seeley added a comment -

        Draft patch... just a few lines of code as proof-of-concept.

        Relevant output looks like so

        "facet_counts":{
        "facet_queries":{},
        "facet_fields":{
        "cat":{
        "camera":0,
        "card":0}}}}

        For the following URL:
        http://localhost:8983/solr/select/?q=a&rows=0&facet=on&facet.field=cat&facet.prefix=ca&wt=json&indent=on

        Only works for the filter method of faceting, not the FieldCache method.
        Would be simple to add though... do a binary search for the prefix in the StringIndex and start there.

        Comments? Is the external API right? facet.prefix (and per-field f.cat.facet.prefix)
        I had considered a more generic facet.field.terms=ca* but Erik's comment about client escaping make me realize it's simpler on both sides to just say "prefix".

        Show
        Yonik Seeley added a comment - Draft patch... just a few lines of code as proof-of-concept. Relevant output looks like so "facet_counts":{ "facet_queries":{}, "facet_fields":{ "cat":{ "camera":0, "card":0}}}} For the following URL: http://localhost:8983/solr/select/?q=a&rows=0&facet=on&facet.field=cat&facet.prefix=ca&wt=json&indent=on Only works for the filter method of faceting, not the FieldCache method. Would be simple to add though... do a binary search for the prefix in the StringIndex and start there. Comments? Is the external API right? facet.prefix (and per-field f.cat.facet.prefix) I had considered a more generic facet.field.terms=ca* but Erik's comment about client escaping make me realize it's simpler on both sides to just say "prefix".
        Hide
        Yonik Seeley added a comment -

        Full patch w/ tests attached.

        This version also implements facet.prefix for the FieldCache method. It also lowers the memory used per-request for that method (because int[] count is smaller since we know the max number of terms beforehand that match the prefix). A binary search is used to find the start and end terms for the prefix.

        Show
        Yonik Seeley added a comment - Full patch w/ tests attached. This version also implements facet.prefix for the FieldCache method. It also lowers the memory used per-request for that method (because int[] count is smaller since we know the max number of terms beforehand that match the prefix). A binary search is used to find the start and end terms for the prefix.
        Hide
        Erik Hatcher added a comment -

        Yonik - I've given this a try - works very well.

        Show
        Erik Hatcher added a comment - Yonik - I've given this a try - works very well.
        Hide
        Yonik Seeley added a comment -

        committed.

        Show
        Yonik Seeley added a comment - committed.
        Hide
        Hoss Man added a comment -

        This bug was modified as part of a bulk update using the criteria...

        • Marked ("Resolved" or "Closed") and "Fixed"
        • Had no "Fix Version" versions
        • Was listed in the CHANGES.txt for 1.2

        The Fix Version for all 39 issues found was set to 1.2, email notification
        was suppressed to prevent excessive email.

        For a list of all the issues modified, search jira comments for this
        (hopefully) unique string: 20080415hossman2

        Show
        Hoss Man added a comment - This bug was modified as part of a bulk update using the criteria... Marked ("Resolved" or "Closed") and "Fixed" Had no "Fix Version" versions Was listed in the CHANGES.txt for 1.2 The Fix Version for all 39 issues found was set to 1.2, email notification was suppressed to prevent excessive email. For a list of all the issues modified, search jira comments for this (hopefully) unique string: 20080415hossman2

          People

          • Assignee:
            Unassigned
            Reporter:
            Yonik Seeley
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development