Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 24F01200CD5 for ; Thu, 22 Jun 2017 07:25:08 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 21D8E160BF3; Thu, 22 Jun 2017 05:25:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8A8D9160C07 for ; Thu, 22 Jun 2017 07:25:06 +0200 (CEST) Received: (qmail 82304 invoked by uid 500); 22 Jun 2017 05:25:05 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 81552 invoked by uid 99); 22 Jun 2017 05:25:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jun 2017 05:25:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1FC3FE96A5; Thu, 22 Jun 2017 05:25:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nightowl888@apache.org To: commits@lucenenet.apache.org Date: Thu, 22 Jun 2017 05:25:34 -0000 Message-Id: <5e0284bb7e2e4a4a8de5e10d0f6f9af7@git.apache.org> In-Reply-To: <231e7073b9444cdc955d02db32d1edee@git.apache.org> References: <231e7073b9444cdc955d02db32d1edee@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [33/38] lucenenet git commit: Lucene.Net.Queries.CommonTermsQuery: Implemented IEnumerable so collection initializer can be used and added documentation to show usage of collection initializer archived-at: Thu, 22 Jun 2017 05:25:08 -0000 Lucene.Net.Queries.CommonTermsQuery: Implemented IEnumerable so collection initializer can be used and 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/a632950c Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a632950c Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a632950c Branch: refs/heads/master Commit: a632950c14a7608e2f98e3f38a740e21d5787c72 Parents: 121684b Author: Shad Storhaug Authored: Wed Jun 21 23:56:32 2017 +0700 Committer: Shad Storhaug Committed: Thu Jun 22 00:13:04 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Queries/CommonTermsQuery.cs | 35 +++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a632950c/src/Lucene.Net.Queries/CommonTermsQuery.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Queries/CommonTermsQuery.cs b/src/Lucene.Net.Queries/CommonTermsQuery.cs index dfc4b4a..701dbd6 100644 --- a/src/Lucene.Net.Queries/CommonTermsQuery.cs +++ b/src/Lucene.Net.Queries/CommonTermsQuery.cs @@ -3,6 +3,7 @@ using Lucene.Net.Search; using Lucene.Net.Support; using Lucene.Net.Util; using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -27,7 +28,7 @@ namespace Lucene.Net.Queries * See the License for the specific language governing permissions and * limitations under the License. */ - + /// /// A query that executes high-frequency terms in a optional sub-query to prevent /// slow queries due to "common" terms like stopwords. This query @@ -52,8 +53,18 @@ namespace Lucene.Net.Queries /// rewritten into a plain conjunction query ie. all high-frequency terms need to /// match in order to match a document. /// + /// + /// Collection initializer note: To create and populate a + /// in a single statement, you can use the following example as a guide: + /// + /// + /// var query = new CommonTermsQuery() { + /// new Term("field", "microsoft"), + /// new Term("field", "office") + /// }; + /// /// - public class CommonTermsQuery : Query + public class CommonTermsQuery : Query, IEnumerable // LUCENENET specific - implemented IEnumerable, which allows for use of collection initializer. See: https://stackoverflow.com/a/9195144 { /* * TODO maybe it would make sense to abstract this even further and allow to @@ -476,5 +487,25 @@ namespace Lucene.Net.Queries { return context == null ? new TermQuery(term) : new TermQuery(term, context); } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// An enumerator that can be used to iterate through the collection. + // LUCENENET specific + public IEnumerator GetEnumerator() + { + return this.m_terms.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// An enumerator that can be used to iterate through the collection. + // LUCENENET specific + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } } } \ No newline at end of file