Lucene - Core
  1. Lucene - Core
  2. LUCENE-544

MultiFieldQueryParser field boost multiplier

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/queryparser
    • Labels:
      None

      Description

      Allows specific boosting per field, e.g. +(name:foo^1 description:foo^0.1).

      Went from String[] field to MultiFieldQueryParser.FieldSetting[] field in constructor.

      1. MultiFieldQueryParser.java
        16 kB
        Karl Wettin
      2. MultiFieldQueryParser.java
        18 kB
        Karl Wettin
      3. MultiFieldQueryParser.java.diff
        26 kB
        Karl Wettin
      4. MultiFieldQueryParser.java.diff
        9 kB
        Karl Wettin
      5. QueryParserPatch
        5 kB
        Matt Ericson

        Activity

        Hide
        Karl Wettin added a comment -

        The updated code

        Show
        Karl Wettin added a comment - The updated code
        Hide
        Karl Wettin added a comment -

        now

        • backwards compatible

        but also

        • serializable (should probably be made externalizable too)
        • has hashCode() and equals()
        Show
        Karl Wettin added a comment - now backwards compatible but also serializable (should probably be made externalizable too) has hashCode() and equals()
        Hide
        Otis Gospodnetic added a comment -

        Karl - can you submit this as a patch/diff, please? I could use this myself, so I'd love to commit this.

        svn diff -bBt ... would probably be good. Also, if you have a patch for MFQP unit test class, please attach those, too.

        Show
        Otis Gospodnetic added a comment - Karl - can you submit this as a patch/diff, please? I could use this myself, so I'd love to commit this. svn diff -bBt ... would probably be good. Also, if you have a patch for MFQP unit test class, please attach those, too.
        Hide
        Karl Wettin added a comment -

        Otis Gospodnetic commented on LUCENE-544:
        > -----------------------------------------
        >
        > Karl - can you submit this as a patch/diff, please?

        Sure. Can you wait for the weekend?

        Show
        Karl Wettin added a comment - Otis Gospodnetic commented on LUCENE-544 : > ----------------------------------------- > > Karl - can you submit this as a patch/diff, please? Sure. Can you wait for the weekend?
        Hide
        Otis Gospodnetic added a comment -

        But of course.

        Show
        Otis Gospodnetic added a comment - But of course.
        Hide
        Karl Wettin added a comment -

        I must have uploaded a bad version last time. Sorry. There was a compilation problem in:

        public static Query parse(String query, String[] fields, Analyzer analyzer)
        throws ParseException {

        but that is a depricated method. I simply removed it in the one I've been running.

        You are getting no test cases this time.
        I have to do some other things first(tm).

        It passes the current though.

        Show
        Karl Wettin added a comment - I must have uploaded a bad version last time. Sorry. There was a compilation problem in: public static Query parse(String query, String[] fields, Analyzer analyzer) throws ParseException { but that is a depricated method. I simply removed it in the one I've been running. You are getting no test cases this time. I have to do some other things first(tm). It passes the current though.
        Hide
        Karl Wettin added a comment -

        A new patch that does not screw up the formatting and that is up to date with 2.0

        Show
        Karl Wettin added a comment - A new patch that does not screw up the formatting and that is up to date with 2.0
        Hide
        Matt Ericson added a comment -

        I have been working on this exact same problem

        Have you created an tests for it?

        I am attaching my version. My version requires use of a map to be passed to the constructor

        Matt

        Show
        Matt Ericson added a comment - I have been working on this exact same problem Have you created an tests for it? I am attaching my version. My version requires use of a map to be passed to the constructor Matt
        Hide
        Matt Ericson added a comment -

        This is my version of the Query Parser that will allow the users to boost some fields

        Show
        Matt Ericson added a comment - This is my version of the Query Parser that will allow the users to boost some fields
        Hide
        Matt Ericson added a comment -

        My Version of the QueryParser that will allow you to boost your fields

        This version used a Map to keep track of what field to boost

        Show
        Matt Ericson added a comment - My Version of the QueryParser that will allow you to boost your fields This version used a Map to keep track of what field to boost
        Hide
        Otis Gospodnetic added a comment -

        I decided to go with Matt's version - smaller change to the class + a unit test. Thanks Matt!

        Karl: if any functionality from your modification is missing after this patch, please feel free to make mods to MFQP in HEAD and attach a patch.

        Show
        Otis Gospodnetic added a comment - I decided to go with Matt's version - smaller change to the class + a unit test. Thanks Matt! Karl: if any functionality from your modification is missing after this patch, please feel free to make mods to MFQP in HEAD and attach a patch.
        Hide
        Karl Wettin added a comment -

        Great stuff Matt! Thanks for the contribution! I didn't use this feature for a while now due to my original messy patchwork. And Otis, I totaly understand you didn't commit that. I wouldn't

        Show
        Karl Wettin added a comment - Great stuff Matt! Thanks for the contribution! I didn't use this feature for a while now due to my original messy patchwork. And Otis, I totaly understand you didn't commit that. I wouldn't
        Hide
        Rene Scheibe added a comment -

        There is a problem with parsing the query "one* two*".

        Using the tests from the patch, I would expect:

        (b:one*^5.0 t:one*^10.0) (b:two*^5.0 t:two*^10.0)

        But I get:

        (b:one* t:one*) (b:two* t:two*)

        Show
        Rene Scheibe added a comment - There is a problem with parsing the query "one* two*". Using the tests from the patch, I would expect: (b:one*^5.0 t:one*^10.0) (b:two*^5.0 t:two*^10.0) But I get: (b:one* t:one*) (b:two* t:two*)

          People

          • Assignee:
            Unassigned
            Reporter:
            Karl Wettin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development