Lucene.Net.Search.DisjunctionMaxQuery: Added documentation to show usage of collection initializer
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/06e1a902 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/06e1a902 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/06e1a902 Branch: refs/heads/master Commit: 06e1a902bda741c89d50254a1fd2cab613c7122c Parents: b1668eb Author: Shad Storhaug <[email protected]> Authored: Sat Jun 17 15:47:56 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Thu Jun 22 00:25:29 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net/Search/DisjunctionMaxQuery.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/06e1a902/src/Lucene.Net/Search/DisjunctionMaxQuery.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Search/DisjunctionMaxQuery.cs b/src/Lucene.Net/Search/DisjunctionMaxQuery.cs index dab4dea..24161e0 100644 --- a/src/Lucene.Net/Search/DisjunctionMaxQuery.cs +++ b/src/Lucene.Net/Search/DisjunctionMaxQuery.cs @@ -32,7 +32,7 @@ namespace Lucene.Net.Search /// <summary> /// A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum /// score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries. - /// this is useful when searching for a word in multiple fields with different boost factors (so that the fields cannot be + /// This is useful when searching for a word in multiple fields with different boost factors (so that the fields cannot be /// combined equivalently into a single search field). We want the primary score to be the one associated with the highest boost, /// not the sum of the field scores (as <see cref="BooleanQuery"/> would give). /// <para/> @@ -44,6 +44,16 @@ namespace Lucene.Net.Search /// The tie breaker capability allows results that include the same term in multiple fields to be judged better than results that /// include this term in only the best of those multiple fields, without confusing this with the better case of two different terms /// in the multiple fields. + /// <para/> + /// Collection initializer note: To create and populate a <see cref="DisjunctionMaxQuery"/> + /// in a single statement, you can use the following example as a guide: + /// + /// <code> + /// var disjunctionMaxQuery = new DisjunctionMaxQuery(0.1f) { + /// new TermQuery(new Term("field1", "albino")), + /// new TermQuery(new Term("field2", "elephant")) + /// }; + /// </code> /// </summary> #if FEATURE_SERIALIZABLE [Serializable] @@ -91,9 +101,9 @@ namespace Lucene.Net.Search /// <summary> /// Add a collection of disjuncts to this disjunction - /// via <see cref="T:ICollection{Query}"/> </summary> + /// via <see cref="T:IEnumerable{Query}"/> </summary> /// <param name="disjuncts"> A collection of queries to add as disjuncts. </param> - public virtual void Add(ICollection<Query> disjuncts) // LUCENENET TODO: API: change back to IEnumerable<Query>. Rename AddRange? + public virtual void Add(ICollection<Query> disjuncts) { this.disjuncts.AddRange(disjuncts); } @@ -104,6 +114,7 @@ namespace Lucene.Net.Search return disjuncts.GetEnumerator(); } + // LUCENENET specific IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator();
