Lucene - Core
  1. Lucene - Core
  2. LUCENE-4009

Implement toString() method in TermsFilter

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.5, 3.6
    • Fix Version/s: 4.1, 5.0
    • Component/s: modules/other
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      LUCENE-1049 introduced a enhanced implementation of the toString() method in the BooleanFilter clause.
      This was an improvement, however I'm still seeing a lot Lucene filter classes not overriding the toString method resulting in a toString returning the classname and the hashcode of the object.
      This can be useful sometimes, but it's totally not useful in my case.
      I want to see the properties set in the filters so I know which Lucene query was created.

      Now:
      BooleanFilter(+BooleanFilter(BooleanFilter(+org.apache.lucene.search.TermsFilter@ea81ba60 +org.apache.lucene.search.TermsFilter@26ea3cbc) BooleanFilter(+org.apache.lucene.search.TermsFilter@df621f09 +org.apache.lucene.search.TermsFilter@2f712446)))

      Wanted behavior:
      BooleanFilter(+BooleanFilter(BooleanFilter(+inStock:Y +barCode:12345678) BooleanFilter(+isHeavy:N +isDamaged:Y)))

        Activity

        Hide
        Uwe Schindler added a comment -

        Closed after release.

        Show
        Uwe Schindler added a comment - Closed after release.
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Michael McCandless
        http://svn.apache.org/viewvc?view=revision&revision=1416513

        LUCENE-4009: improve TermsFilter.toString

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Michael McCandless http://svn.apache.org/viewvc?view=revision&revision=1416513 LUCENE-4009 : improve TermsFilter.toString
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Michael McCandless
        http://svn.apache.org/viewvc?view=revision&revision=1416513

        LUCENE-4009: improve TermsFilter.toString

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Michael McCandless http://svn.apache.org/viewvc?view=revision&revision=1416513 LUCENE-4009 : improve TermsFilter.toString
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] Michael McCandless
        http://svn.apache.org/viewvc?view=revision&revision=1416509

        LUCENE-4009: improve TermsFilter.toString

        Show
        Commit Tag Bot added a comment - [trunk commit] Michael McCandless http://svn.apache.org/viewvc?view=revision&revision=1416509 LUCENE-4009 : improve TermsFilter.toString
        Hide
        Michael McCandless added a comment -

        Thanks Tim!

        Show
        Michael McCandless added a comment - Thanks Tim!
        Hide
        Michael McCandless added a comment -

        Thanks Tim, I'll merge & commit ...

        Show
        Michael McCandless added a comment - Thanks Tim, I'll merge & commit ...
        Hide
        Tim Costermans added a comment - - edited

        Hi Chris,
        Sorry for the delay, I didn't notice your comment.
        I'm ok with your changes.
        You can commit this.

        Show
        Tim Costermans added a comment - - edited Hi Chris, Sorry for the delay, I didn't notice your comment. I'm ok with your changes. You can commit this.
        Hide
        Chris Male added a comment -

        Hi Tim

        I've simplified the patch a little, can you check you're okay with it? If so, I'll commit.

        Show
        Chris Male added a comment - Hi Tim I've simplified the patch a little, can you check you're okay with it? If so, I'll commit.
        Hide
        Tim Costermans added a comment -

        Hey Chris,

        Basically all the subclasses of org.apache.lucene.search.Filter should implement their own toString() method.
        Maybe this can be enforced by adding this to the Filter class.

        @Override
        public abstract String  toString();
        

        I was going to investigate this, but this will be something for next week.

        Show
        Tim Costermans added a comment - Hey Chris, Basically all the subclasses of org.apache.lucene.search.Filter should implement their own toString() method. Maybe this can be enforced by adding this to the Filter class. @Override public abstract String toString(); I was going to investigate this, but this will be something for next week.
        Hide
        Tim Costermans added a comment -

        Discard previous patch. Only import this one. Improved implementation of toString() in TermsFilter + added a test for it.

        Show
        Tim Costermans added a comment - Discard previous patch. Only import this one. Improved implementation of toString() in TermsFilter + added a test for it.
        Hide
        Chris Male added a comment -

        Hey Tim,

        however I'm still seeing a lot Lucene filter classes not overriding the toString

        Know of any more? If so, want to put together a bigger patch and we'll tackle them here?

        Show
        Chris Male added a comment - Hey Tim, however I'm still seeing a lot Lucene filter classes not overriding the toString Know of any more? If so, want to put together a bigger patch and we'll tackle them here?
        Hide
        Tim Costermans added a comment -

        Patch + test

        Show
        Tim Costermans added a comment - Patch + test

          People

          • Assignee:
            Michael McCandless
            Reporter:
            Tim Costermans
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development