You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Shai Erera (JIRA)" <ji...@apache.org> on 2014/01/06 22:03:50 UTC

[jira] [Created] (LUCENE-5387) Improve FacetConfig.build

Shai Erera created LUCENE-5387:
----------------------------------

             Summary: Improve FacetConfig.build
                 Key: LUCENE-5387
                 URL: https://issues.apache.org/jira/browse/LUCENE-5387
             Project: Lucene - Core
          Issue Type: Improvement
          Components: modules/facet
            Reporter: Shai Erera
            Assignee: Shai Erera


FacetConfig.build() takes an IndexDocument and returns a new instance of IndexDocument. This forces you to write code like this:

{code}
Document doc = new Document();
doc.add(new StringField("id", "someID", Store.NO));
doc.add(new FacetField("author", "john"));
IndexDocument facetDoc = facetConfig.build(doc);
indexWriter.addDocument(facetDoc);
{code}

Technically, you don't need to declare 'facetDoc', you could just {{indexWriter.addDocument(facetConfig.build(doc))}}, but it's weird:

* After you call facetConfig.build(), you cannot add any more fields to the document (since you get an IndexDoc), so you must call it last.

* Nothing suggests you *should* call facetConfig.build() at all - I can already see users trapped by the new API, thinking that adding a FacetField is enough. We should at least document on FacetField that you should call FacetConfig.build().

* Nothing suggests that you shouldn't ignore the returned IndexDoc from FC.build() - we should at least document that.

I think that if FacetConfig.build() took an IndexDocument but returned a Document, that will at least allow you to call it in whatever stage of the pipeline that you want (after adding all FacetFields though)...

I'll post a patch later.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org