From 5f63bbea30273a6f43397ea5889d8168677c4f92 Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Sun, 21 Feb 2021 22:54:32 +0700 Subject: [PATCH 1/7] Lucene.Net.Tests.Queries: Use consistent license headers (#259) --- .../BooleanFilterTest.cs | 40 +++++++++---------- .../BoostingQueryTest.cs | 40 +++++++++---------- .../ChainedFilterTest.cs | 40 +++++++++---------- .../CommonTermsQueryTest.cs | 40 +++++++++---------- .../Function/FunctionTestSetup.cs | 40 +++++++++---------- .../Function/TestBoostedQuery.cs | 40 +++++++++---------- .../Function/TestDocValuesFieldSources.cs | 40 +++++++++---------- .../Function/TestFieldScoreQuery.cs | 40 +++++++++---------- .../Function/TestFunctionQuerySort.cs | 40 +++++++++---------- .../Function/TestLongNormValueSource.cs | 40 +++++++++---------- .../Function/TestOrdValues.cs | 40 +++++++++---------- .../Function/TestValueSources.cs | 40 +++++++++---------- .../Mlt/TestMoreLikeThis.cs | 40 +++++++++---------- .../TermFilterTest.cs | 40 +++++++++---------- .../TermsFilterTest.cs | 40 +++++++++---------- .../TestCustomScoreQuery.cs | 40 +++++++++---------- 16 files changed, 288 insertions(+), 352 deletions(-) diff --git a/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs b/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs index 6653f9cd53..b4159a50c7 100644 --- a/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using Lucene.Net.Analysis; +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Queries; @@ -30,6 +9,23 @@ namespace Lucene.Net.Tests.Queries { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class BooleanFilterTest : LuceneTestCase { private Directory directory; diff --git a/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs b/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs index 2d18840954..d890a26bbf 100644 --- a/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs +++ b/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using Lucene.Net.Index; +using Lucene.Net.Index; using Lucene.Net.Queries; using Lucene.Net.Search; using Lucene.Net.Util; @@ -27,6 +6,23 @@ namespace Lucene.Net.Tests.Queries { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class BoostingQueryTest : LuceneTestCase { // TODO: this suite desperately needs more tests! diff --git a/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs b/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs index e764319b66..5564420fba 100644 --- a/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using System.Globalization; using Lucene.Net.Documents; using Lucene.Net.Index; @@ -31,6 +10,23 @@ namespace Lucene.Net.Tests.Queries { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class ChainedFilterTest : LuceneTestCase { public const int Max = 500; diff --git a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs index 320e8e290d..ddaf36f367 100644 --- a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs +++ b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using System.Collections.Generic; using Lucene.Net.Analysis; using Lucene.Net.Documents; @@ -33,6 +12,23 @@ namespace Lucene.Net.Tests.Queries { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class CommonTermsQueryTest : LuceneTestCase { [Test] diff --git a/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs b/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs index c9decbdcbd..e4f3737948 100644 --- a/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs +++ b/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; @@ -33,6 +12,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// /// Setup for function tests /// diff --git a/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs b/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs index b04ccf108c..dc82e186c4 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using Lucene.Net.Analysis; +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Index.Extensions; @@ -32,6 +11,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// /// Basic tests for /// diff --git a/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs b/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs index b190324b03..71cfce74fe 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using Lucene.Net.Analysis; +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Queries.Function; @@ -35,6 +14,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + [SuppressCodecs("Lucene3x")] public class TestDocValuesFieldSources : LuceneTestCase { diff --git a/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs b/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs index 2b5ee6950c..1951dd7851 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using J2N.Text; +using J2N.Text; using Lucene.Net.Index; using Lucene.Net.Queries.Function; using Lucene.Net.Search; @@ -27,6 +6,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// /// Test FieldScoreQuery search. ///

diff --git a/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs b/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs index 4537b36b43..768dd6f2cf 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Index.Extensions; @@ -31,6 +10,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + ///

/// Test that functionquery's getSortField() actually works. /// diff --git a/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs b/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs index 066d86269b..01030d278e 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using Lucene.Net.Analysis; +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Index.Extensions; @@ -35,6 +14,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + [SuppressCodecs("Lucene3x")] public class TestLongNormValueSource : LuceneTestCase { diff --git a/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs b/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs index c5e2841f39..ef5c41b765 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using J2N.Text; +using J2N.Text; using Lucene.Net.Index; using Lucene.Net.Queries.Function; using Lucene.Net.Queries.Function.ValueSources; @@ -29,6 +8,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// /// Test search based on OrdFieldSource and ReverseOrdFieldSource. ///

diff --git a/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs b/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs index e78ad71fb4..96943f61ef 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using System.Collections.Generic; using Lucene.Net.Analysis; using Lucene.Net.Codecs; @@ -36,6 +15,23 @@ namespace Lucene.Net.Tests.Queries.Function { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // TODO: add separate docvalues test ///

/// barebones tests for function queries. diff --git a/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs b/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs index d628238ec0..2f492e61e1 100644 --- a/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs +++ b/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using Lucene.Net.Analysis; using Lucene.Net.Documents; @@ -32,6 +11,23 @@ namespace Lucene.Net.Tests.Queries.Mlt { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class TestMoreLikeThis : LuceneTestCase { private Directory directory; diff --git a/src/Lucene.Net.Tests.Queries/TermFilterTest.cs b/src/Lucene.Net.Tests.Queries/TermFilterTest.cs index 9044639a8b..c4a403c3db 100644 --- a/src/Lucene.Net.Tests.Queries/TermFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/TermFilterTest.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using System.Collections.Generic; using Lucene.Net.Documents; using Lucene.Net.Index; @@ -32,6 +11,23 @@ namespace Lucene.Net.Tests.Queries { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class TermFilterTest : LuceneTestCase { [Test] diff --git a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs index e9df545745..45b1add33d 100644 --- a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using System.Collections.Generic; using System.Linq; using J2N.Collections.Generic.Extensions; @@ -35,6 +14,23 @@ namespace Lucene.Net.Tests.Queries { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public class TermsFilterTest : LuceneTestCase { [Test] diff --git a/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs b/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs index 16805f3c36..47d3052808 100644 --- a/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs +++ b/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs @@ -1,25 +1,4 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -using System; +using System; using System.Collections.Generic; using Lucene.Net.Index; using Lucene.Net.Queries; @@ -30,6 +9,23 @@ namespace Lucene.Net.Tests.Queries { + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// /// Test CustomScoreQuery search. /// From 78f07cf3ec02b1662f12d962b542af292232567a Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Sun, 21 Feb 2021 23:03:32 +0700 Subject: [PATCH 2/7] Lucene.Net.Tests.Queries: Removed unused imports (#259) --- .../Function/TestDocValuesFieldSources.cs | 1 - src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs b/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs index 71cfce74fe..cf27cbd1ef 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs @@ -5,7 +5,6 @@ using Lucene.Net.Queries.Function.ValueSources; using Lucene.Net.Randomized.Generators; using Lucene.Net.Store; -using Lucene.Net.Support; using Lucene.Net.Util; using Lucene.Net.Util.Packed; using NUnit.Framework; diff --git a/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs b/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs index 01030d278e..753d06fd4e 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs @@ -7,7 +7,6 @@ using Lucene.Net.Search; using Lucene.Net.Search.Similarities; using Lucene.Net.Store; -using Lucene.Net.Support; using Lucene.Net.Util; using NUnit.Framework; using System; From 10870c9fe0d521d13ae551aa34c5708fee64ef3d Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Mon, 22 Feb 2021 00:19:31 +0700 Subject: [PATCH 3/7] BUG: Lucene.Net.Tests.Queries.Function.TestFieldScoreQuery: Added missing [Test] attributes (#259) --- .../Function/TestFieldScoreQuery.cs | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs b/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs index 1951dd7851..bdb2e6ba4f 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs @@ -115,10 +115,8 @@ private void DoTestRank(ValueSource valueSource) /// /// Test that FieldScoreQuery of Type.BYTE returns the expected scores. - //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: - //ORIGINAL LINE: @Test public void testExactScoreByte() throws Exception - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - public virtual void testExactScoreByte() + [Test] + public virtual void TestExactScoreByte() { // INT field values are small enough to be parsed as byte doTestExactScore(BYTE_VALUESOURCE); @@ -126,10 +124,8 @@ public virtual void testExactScoreByte() /// /// Test that FieldScoreQuery of Type.SHORT returns the expected scores. - //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: - //ORIGINAL LINE: @Test public void testExactScoreShort() throws Exception - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - public virtual void testExactScoreShort() + [Test] + public virtual void TestExactScoreShort() { // INT field values are small enough to be parsed as short doTestExactScore(SHORT_VALUESOURCE); @@ -137,20 +133,16 @@ public virtual void testExactScoreShort() /// /// Test that FieldScoreQuery of Type.INT returns the expected scores. - //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: - //ORIGINAL LINE: @Test public void testExactScoreInt() throws Exception - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - public virtual void testExactScoreInt() + [Test] + public virtual void TestExactScoreInt() { doTestExactScore(INT_VALUESOURCE); } /// /// Test that FieldScoreQuery of Type.FLOAT returns the expected scores. - //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: - //ORIGINAL LINE: @Test public void testExactScoreFloat() throws Exception - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - public virtual void testExactScoreFloat() + [Test] + public virtual void TestExactScoreFloat() { // INT field can be parsed as float doTestExactScore(INT_AS_FLOAT_VALUESOURCE); @@ -159,8 +151,6 @@ public virtual void testExactScoreFloat() } // Test that FieldScoreQuery returns docs with expected score. - //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: - //ORIGINAL LINE: private void doTestExactScore(ValueSource valueSource) throws Exception private void doTestExactScore(ValueSource valueSource) { FunctionQuery functionQuery = new FunctionQuery(valueSource); @@ -179,6 +169,5 @@ private void doTestExactScore(ValueSource valueSource) } r.Dispose(); } - } } From f065f813b46a1bf37200064edc8b22bdfa86628c Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Mon, 22 Feb 2021 04:26:44 +0700 Subject: [PATCH 4/7] SWEEP: MemberwiseClone() doesn't throw exceptions in .NET, so there is no need to place it in a try/catch block. There is also no need to cast the result if we don't need access to its members. (#259) --- src/Lucene.Net/Search/Query.cs | 11 ++--------- src/Lucene.Net/Util/InfoStream.cs | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Lucene.Net/Search/Query.cs b/src/Lucene.Net/Search/Query.cs index c2825d61c6..26e86f4fb6 100644 --- a/src/Lucene.Net/Search/Query.cs +++ b/src/Lucene.Net/Search/Query.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace Lucene.Net.Search @@ -117,14 +117,7 @@ public virtual void ExtractTerms(ISet terms) /// Returns a clone of this query. public virtual object Clone() { - try - { - return (Query)base.MemberwiseClone(); - } - catch (Exception e) - { - throw new Exception("Clone not supported: " + e.Message); - } + return MemberwiseClone(); // LUCENENET: MemberwiseClone() never throws in .NET and there is no need to cast the result here. } public override int GetHashCode() diff --git a/src/Lucene.Net/Util/InfoStream.cs b/src/Lucene.Net/Util/InfoStream.cs index d29a68433a..30e801494d 100644 --- a/src/Lucene.Net/Util/InfoStream.cs +++ b/src/Lucene.Net/Util/InfoStream.cs @@ -1,4 +1,4 @@ -using System; +using System; using Lucene.Net.Diagnostics; namespace Lucene.Net.Util @@ -110,14 +110,7 @@ protected virtual void Dispose(bool disposing) ///
public virtual object Clone() { - try - { - return (InfoStream)base.MemberwiseClone(); - } - catch (InvalidOperationException e) - { - throw new Exception(e.ToString(), e); - } + return MemberwiseClone(); // LUCENENET: No exception can occur in .NET and there is no need to cast. } } } \ No newline at end of file From 08c44cfce338d6913f1687101e7cea964e4c0999 Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Mon, 22 Feb 2021 04:27:50 +0700 Subject: [PATCH 5/7] Lucene.Net.Index.Term: Added TODO about converting Text() to a property (#259) --- src/Lucene.Net/Index/Term.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Lucene.Net/Index/Term.cs b/src/Lucene.Net/Index/Term.cs index 3183474458..34bc92c1ea 100644 --- a/src/Lucene.Net/Index/Term.cs +++ b/src/Lucene.Net/Index/Term.cs @@ -1,4 +1,4 @@ -using J2N.Text; +using J2N.Text; using System; using System.Text; @@ -84,7 +84,7 @@ public Term(string fld) /// text of the word. In the case of dates and other types, this is an /// encoding of the object as a string. ///
- public string Text() + public string Text() // LUCENENET TODO: API - Change to a property. While this calls a method internally, its expected usage is that it will return a deterministic value. { return ToString(Bytes); } From e49965270aa0902cdeba11552e2c9cd669a6a714 Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Mon, 22 Feb 2021 06:46:47 +0700 Subject: [PATCH 6/7] BUG: Lucene.Net.Tests.Queries.TermsFilterTest::TestSingleFieldEquals(): Hash code collision provided in Lucene won't necessarily be a collision in .NET. Generate the collision at runtime so the test will pass (the test wouldn't have passed if the assert hadn't been commented). (#259) --- .../TermsFilterTest.cs | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs index 45b1add33d..7627f18865 100644 --- a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs @@ -339,13 +339,50 @@ public void TestHashCodeAndEquals() [Test] public void TestSingleFieldEquals() { - // Two terms with the same hash code + //// Two terms with the same hash code //assertEquals("AaAaBB".GetHashCode(), "BBBBBB".GetHashCode()); - TermsFilter left = TermsFilter(true, new Term("id", "AaAaAa"), new Term("id", "AaAaBB")); - TermsFilter right = TermsFilter(true, new Term("id", "AaAaAa"), new Term("id", "BBBBBB")); + //TermsFilter left = TermsFilter(true, new Term("id", "AaAaAa"), new Term("id", "AaAaBB")); + //TermsFilter right = TermsFilter(true, new Term("id", "AaAaAa"), new Term("id", "BBBBBB")); + //assertFalse(left.Equals(right)); + + // LUCENENET specific - since in .NET the hash code is dependent on the underlying + // target framework, we need to generate a collision at runtime. + GenerateHashCollision(out string theString, out string stringWithCollision); + assertEquals(theString.GetHashCode(), stringWithCollision.GetHashCode()); + TermsFilter left = TermsFilter(true, new Term("id", "AaAaAa"), new Term("id", theString)); + TermsFilter right = TermsFilter(true, new Term("id", "AaAaAa"), new Term("id", stringWithCollision)); assertFalse(left.Equals(right)); } + // LUCENENET specific - since in .NET the hash code is dependent on the underlying + // target framework, we need to generate a collision at runtime. + // Source: https://stackoverflow.com/a/32027473 + private static void GenerateHashCollision(out string theString, out string stringWithCollision) + { + var words = new Dictionary(); + + int i = 0; + string teststring; + while (true) + { + i++; + teststring = i.ToString(); + try + { + words.Add(teststring.GetHashCode(), teststring); + } + catch (Exception) + { + break; + } + } + + var collisionHash = teststring.GetHashCode(); + + theString = teststring; + stringWithCollision = words[collisionHash]; + } + [Test] public void TestNoTerms() { From de45ee53b9a2722238e6f9ac4c5e2461eda18834 Mon Sep 17 00:00:00 2001 From: Shad Storhaug Date: Mon, 22 Feb 2021 07:30:26 +0700 Subject: [PATCH 7/7] Lucene.Net.Queries, Lucene.Net.Tests.Queries: Marked lucene compatibility version 4.8.1 at the top of each file. (#259) --- src/Lucene.Net.Queries/BooleanFilter.cs | 3 +- src/Lucene.Net.Queries/BoostingQuery.cs | 3 +- src/Lucene.Net.Queries/ChainedFilter.cs | 3 +- src/Lucene.Net.Queries/CommonTermsQuery.cs | 3 +- src/Lucene.Net.Queries/CustomScoreProvider.cs | 3 +- src/Lucene.Net.Queries/CustomScoreQuery.cs | 3 +- src/Lucene.Net.Queries/FilterClause.cs | 3 +- .../Function/BoostedQuery.cs | 3 +- .../Function/DocValues/BoolDocValues.cs | 3 +- .../DocValues/DocTermsIndexDocValues.cs | 3 +- .../Function/DocValues/DoubleDocValues.cs | 3 +- .../Function/DocValues/FloatDocValues.cs | 3 +- .../Function/DocValues/IntDocValues.cs | 3 +- .../Function/DocValues/LongDocValues.cs | 3 +- .../Function/DocValues/StrDocValues.cs | 3 +- .../Function/FunctionQuery.cs | 3 +- .../Function/FunctionValues.cs | 3 +- .../Function/ValueSource.cs | 3 +- .../Function/ValueSourceScorer.cs | 3 +- .../Function/ValueSources/BoolFunction.cs | 4 +- .../Function/ValueSources/ByteFieldSource.cs | 3 +- .../ValueSources/BytesRefFieldSource.cs | 3 +- .../ValueSources/ConstNumberSource.cs | 4 +- .../Function/ValueSources/ConstValueSource.cs | 3 +- .../Function/ValueSources/DefFunction.cs | 3 +- .../Function/ValueSources/DivFloatFunction.cs | 4 +- .../ValueSources/DocFreqValueSource.cs | 3 +- .../ValueSources/DoubleConstValueSource.cs | 3 +- .../ValueSources/DoubleFieldSource.cs | 3 +- .../ValueSources/DualFloatFunction.cs | 3 +- .../Function/ValueSources/EnumFieldSource.cs | 3 +- .../Function/ValueSources/FieldCacheSource.cs | 3 +- .../Function/ValueSources/FloatFieldSource.cs | 3 +- .../Function/ValueSources/IDFValueSource.cs | 3 +- .../Function/ValueSources/IfFunction.cs | 3 +- .../Function/ValueSources/IntFieldSource.cs | 3 +- .../ValueSources/JoinDocFreqValueSource.cs | 3 +- .../ValueSources/LinearFloatFunction.cs | 3 +- .../ValueSources/LiteralValueSource.cs | 3 +- .../Function/ValueSources/LongFieldSource.cs | 3 +- .../ValueSources/MaxDocValueSource.cs | 3 +- .../Function/ValueSources/MaxFloatFunction.cs | 3 +- .../Function/ValueSources/MinFloatFunction.cs | 3 +- .../ValueSources/MultiBoolFunction.cs | 3 +- .../ValueSources/MultiFloatFunction.cs | 3 +- .../Function/ValueSources/MultiFunction.cs | 3 +- .../Function/ValueSources/MultiValueSource.cs | 4 +- .../Function/ValueSources/NormValueSource.cs | 3 +- .../ValueSources/NumDocsValueSource.cs | 3 +- .../Function/ValueSources/OrdFieldSource.cs | 3 +- .../Function/ValueSources/PowFloatFunction.cs | 3 +- .../ValueSources/ProductFloatFunction.cs | 4 +- .../Function/ValueSources/QueryValueSource.cs | 3 +- .../ValueSources/RangeMapFloatFunction.cs | 3 +- .../ValueSources/ReciprocalFloatFunction.cs | 3 +- .../ValueSources/ReverseOrdFieldSource.cs | 3 +- .../ValueSources/ScaleFloatFunction.cs | 3 +- .../Function/ValueSources/ShortFieldSource.cs | 3 +- .../ValueSources/SimpleBoolFunction.cs | 3 +- .../ValueSources/SimpleFloatFunction.cs | 3 +- .../Function/ValueSources/SingleFunction.cs | 3 +- .../Function/ValueSources/SumFloatFunction.cs | 4 +- .../SumTotalTermFreqValueSource.cs | 3 +- .../Function/ValueSources/TFValueSource.cs | 3 +- .../ValueSources/TermFreqValueSource.cs | 3 +- .../ValueSources/TotalTermFreqValueSource.cs | 3 +- .../ValueSources/VectorValueSource.cs | 3 +- src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs | 3 +- .../Mlt/MoreLikeThisQuery.cs | 3 +- src/Lucene.Net.Queries/TermFilter.cs | 3 +- src/Lucene.Net.Queries/TermsFilter.cs | 3 +- .../BooleanFilterTest.cs | 56 +++++-- .../BoostingQueryTest.cs | 3 +- .../ChainedFilterTest.cs | 21 ++- .../CommonTermsQueryTest.cs | 158 ++++++++++++------ .../Function/FunctionTestSetup.cs | 41 +++-- .../Function/TestBoostedQuery.cs | 3 +- .../Function/TestDocValuesFieldSources.cs | 3 +- .../Function/TestFieldScoreQuery.cs | 3 +- .../Function/TestFunctionQuerySort.cs | 8 +- .../Function/TestLongNormValueSource.cs | 9 +- .../Function/TestOrdValues.cs | 11 +- .../Function/TestValueSources.cs | 143 +++++++++++----- .../Mlt/TestMoreLikeThis.cs | 6 +- .../TermFilterTest.cs | 19 ++- .../TermsFilterTest.cs | 17 +- .../TestCustomScoreQuery.cs | 32 ++-- 87 files changed, 508 insertions(+), 244 deletions(-) diff --git a/src/Lucene.Net.Queries/BooleanFilter.cs b/src/Lucene.Net.Queries/BooleanFilter.cs index 24caf4ac26..7f0601cd45 100644 --- a/src/Lucene.Net.Queries/BooleanFilter.cs +++ b/src/Lucene.Net.Queries/BooleanFilter.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Diagnostics; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Diagnostics; using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/BoostingQuery.cs b/src/Lucene.Net.Queries/BoostingQuery.cs index 7a6c142aae..3680992fb0 100644 --- a/src/Lucene.Net.Queries/BoostingQuery.cs +++ b/src/Lucene.Net.Queries/BoostingQuery.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; namespace Lucene.Net.Queries diff --git a/src/Lucene.Net.Queries/ChainedFilter.cs b/src/Lucene.Net.Queries/ChainedFilter.cs index a9c43f99a4..045f9da330 100644 --- a/src/Lucene.Net.Queries/ChainedFilter.cs +++ b/src/Lucene.Net.Queries/ChainedFilter.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; using System; diff --git a/src/Lucene.Net.Queries/CommonTermsQuery.cs b/src/Lucene.Net.Queries/CommonTermsQuery.cs index 69ed7e033a..01fd66643b 100644 --- a/src/Lucene.Net.Queries/CommonTermsQuery.cs +++ b/src/Lucene.Net.Queries/CommonTermsQuery.cs @@ -1,4 +1,5 @@ -using J2N.Collections.Generic.Extensions; +// Lucene version compatibility level 4.8.1 +using J2N.Collections.Generic.Extensions; using Lucene.Net.Diagnostics; using Lucene.Net.Index; using Lucene.Net.Search; diff --git a/src/Lucene.Net.Queries/CustomScoreProvider.cs b/src/Lucene.Net.Queries/CustomScoreProvider.cs index 3ad6f1ecee..d9d430f92e 100644 --- a/src/Lucene.Net.Queries/CustomScoreProvider.cs +++ b/src/Lucene.Net.Queries/CustomScoreProvider.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; namespace Lucene.Net.Queries diff --git a/src/Lucene.Net.Queries/CustomScoreQuery.cs b/src/Lucene.Net.Queries/CustomScoreQuery.cs index 18e3d84f15..243b6f844b 100644 --- a/src/Lucene.Net.Queries/CustomScoreQuery.cs +++ b/src/Lucene.Net.Queries/CustomScoreQuery.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function; using Lucene.Net.Search; using Lucene.Net.Support; diff --git a/src/Lucene.Net.Queries/FilterClause.cs b/src/Lucene.Net.Queries/FilterClause.cs index a288ca38f8..251e13f74b 100644 --- a/src/Lucene.Net.Queries/FilterClause.cs +++ b/src/Lucene.Net.Queries/FilterClause.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Search; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Search; namespace Lucene.Net.Queries { diff --git a/src/Lucene.Net.Queries/Function/BoostedQuery.cs b/src/Lucene.Net.Queries/Function/BoostedQuery.cs index 844d02d9f0..23464b77d9 100644 --- a/src/Lucene.Net.Queries/Function/BoostedQuery.cs +++ b/src/Lucene.Net.Queries/Function/BoostedQuery.cs @@ -1,4 +1,5 @@ -using J2N.Numerics; +// Lucene version compatibility level 4.8.1 +using J2N.Numerics; using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs index dc9d43b683..539853a65d 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/BoolDocValues.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using Lucene.Net.Util.Mutable; namespace Lucene.Net.Queries.Function.DocValues diff --git a/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs index eb7c280d1f..8178834dbe 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; using Lucene.Net.Util.Mutable; diff --git a/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs index 8ed8e0d6cf..7477e8d063 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/DoubleDocValues.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Util.Mutable; using System; using System.Globalization; diff --git a/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs index 0d8fe10b08..8d1f66ea17 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/FloatDocValues.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Util.Mutable; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Util.Mutable; using System; using System.Globalization; diff --git a/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs index 58c8a058ca..9102b33f43 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/IntDocValues.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Util.Mutable; using System; using System.Globalization; diff --git a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs index 6f204e22c6..929a5bbd03 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Util.Mutable; using System; using System.Globalization; diff --git a/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs index 36d8089429..767a40fc8f 100644 --- a/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs +++ b/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Util.Mutable; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Util.Mutable; namespace Lucene.Net.Queries.Function.DocValues { diff --git a/src/Lucene.Net.Queries/Function/FunctionQuery.cs b/src/Lucene.Net.Queries/Function/FunctionQuery.cs index 02b7fc75de..0e37451025 100644 --- a/src/Lucene.Net.Queries/Function/FunctionQuery.cs +++ b/src/Lucene.Net.Queries/Function/FunctionQuery.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/FunctionValues.cs b/src/Lucene.Net.Queries/Function/FunctionValues.cs index 251a33ec0c..71aebbf6da 100644 --- a/src/Lucene.Net.Queries/Function/FunctionValues.cs +++ b/src/Lucene.Net.Queries/Function/FunctionValues.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using System.Globalization; using Lucene.Net.Index; using Lucene.Net.Search; diff --git a/src/Lucene.Net.Queries/Function/ValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource.cs index 26f5cd5aaf..e075efb8ec 100644 --- a/src/Lucene.Net.Queries/Function/ValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSource.cs @@ -1,4 +1,5 @@ -using J2N.Runtime.CompilerServices; +// Lucene version compatibility level 4.8.1 +using J2N.Runtime.CompilerServices; using Lucene.Net.Index; using Lucene.Net.Search; using System; diff --git a/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs b/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs index 24cdbbae5f..78528ed8d3 100644 --- a/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs +++ b/src/Lucene.Net.Queries/Function/ValueSourceScorer.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; using System; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/BoolFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/BoolFunction.cs index 3470fb346f..fac6947eae 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/BoolFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/BoolFunction.cs @@ -1,4 +1,6 @@ -namespace Lucene.Net.Queries.Function.ValueSources +// Lucene version compatibility level 4.8.1 + +namespace Lucene.Net.Queries.Function.ValueSources { /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs index 5279ffe08a..2597644bfb 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using System; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs index 1903796992..21b8150caf 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Util; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs index 3a33ae79fd..d8d0aa33d7 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs @@ -1,4 +1,6 @@ -namespace Lucene.Net.Queries.Function.ValueSources +// Lucene version compatibility level 4.8.1 + +namespace Lucene.Net.Queries.Function.ValueSources { /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs index 607bd57270..7c8fa1d9ef 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs index b12c4c8978..aff62e205f 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Util; using System.Collections; using System.Collections.Generic; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs index 20b91c6328..b8a4c3cd3b 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs @@ -1,4 +1,6 @@ -namespace Lucene.Net.Queries.Function.ValueSources +// Lucene version compatibility level 4.8.1 + +namespace Lucene.Net.Queries.Function.ValueSources { /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs index f277a975f1..9d40d9f171 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DocFreqValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs index f7b8d028ce..1f4f5e6e37 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs @@ -1,4 +1,5 @@ -using J2N.Numerics; +// Lucene version compatibility level 4.8.1 +using J2N.Numerics; using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using System; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs index a823e52ee4..55dd2f88d8 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs index fc69e4796d..c842d3acf4 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/DualFloatFunction.cs @@ -1,4 +1,5 @@ -using J2N.Numerics; +// Lucene version compatibility level 4.8.1 +using J2N.Numerics; using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs index c1dc8efc87..dceac9ef56 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs index a8ec5c3c54..e9ce82c4da 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Search; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Search; using System; namespace Lucene.Net.Queries.Function.ValueSources diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs index f09a12764b..bb245c0243 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs index 7d2da7210d..e64c3c3569 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Search.Similarities; using Lucene.Net.Support; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs index 2c13413812..ee1609f568 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/IfFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs index ac11ed050b..d48b2a143f 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/IntFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs index 9054c0de06..76b42e16ff 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/JoinDocFreqValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Util; using Lucene.Net.Util.Packed; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs index 2a08aa6e0c..7b3d1bfb19 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/LinearFloatFunction.cs @@ -1,4 +1,5 @@ -using J2N.Numerics; +// Lucene version compatibility level 4.8.1 +using J2N.Numerics; using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/LiteralValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/LiteralValueSource.cs index 2dd7b38736..8b792fd3e1 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/LiteralValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/LiteralValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Util; using System; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs index 3d6653c9aa..cb73a87325 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/LongFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MaxDocValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/MaxDocValueSource.cs index cf7d616bb0..0db04f5369 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MaxDocValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MaxDocValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs index b68cee3dd1..4f219424db 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MaxFloatFunction.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; namespace Lucene.Net.Queries.Function.ValueSources { diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs index eab6c2da81..6391993b72 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MinFloatFunction.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; namespace Lucene.Net.Queries.Function.ValueSources { diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs index 19bf4fe94e..0a859ef26f 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MultiBoolFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs index aaa0bbbe5e..96e8581be3 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MultiFloatFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Support; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs index e78e041ae3..623e101690 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MultiFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using System.Collections; using System.Collections.Generic; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/MultiValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/MultiValueSource.cs index 08c8d5108c..5b83eeb2fc 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/MultiValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/MultiValueSource.cs @@ -1,4 +1,6 @@ -namespace Lucene.Net.Queries.Function.ValueSources +// Lucene version compatibility level 4.8.1 + +namespace Lucene.Net.Queries.Function.ValueSources { /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs index d8e6deb448..6a270ab7d5 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/NormValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Search.Similarities; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/NumDocsValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/NumDocsValueSource.cs index de5467f159..f6749fe53d 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/NumDocsValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/NumDocsValueSource.cs @@ -1,4 +1,5 @@ -using System.Collections; +// Lucene version compatibility level 4.8.1 +using System.Collections; using Lucene.Net.Index; namespace Lucene.Net.Queries.Function.ValueSources diff --git a/src/Lucene.Net.Queries/Function/ValueSources/OrdFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/OrdFieldSource.cs index 8bdc8d9550..69fcf33cf1 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/OrdFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/OrdFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util.Mutable; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/PowFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/PowFloatFunction.cs index 2328bfe790..0108f452f1 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/PowFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/PowFloatFunction.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; namespace Lucene.Net.Queries.Function.ValueSources { diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ProductFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/ProductFloatFunction.cs index a42e4e72bd..9b06801975 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ProductFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ProductFloatFunction.cs @@ -1,4 +1,6 @@ -namespace Lucene.Net.Queries.Function.ValueSources +// Lucene version compatibility level 4.8.1 + +namespace Lucene.Net.Queries.Function.ValueSources { /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/src/Lucene.Net.Queries/Function/ValueSources/QueryValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/QueryValueSource.cs index 598536f8e7..cb72e98b4a 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/QueryValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/QueryValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs index 03389c6caf..5b436ca20d 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/RangeMapFloatFunction.cs @@ -1,4 +1,5 @@ -using J2N.Numerics; +// Lucene version compatibility level 4.8.1 +using J2N.Numerics; using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs index e5bbb325e3..3e441464a6 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ReciprocalFloatFunction.cs @@ -1,4 +1,5 @@ -using J2N.Numerics; +// Lucene version compatibility level 4.8.1 +using J2N.Numerics; using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ReverseOrdFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ReverseOrdFieldSource.cs index 75c5f48aa0..6e98b73425 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ReverseOrdFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ReverseOrdFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using System; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs index e7d5584486..0d33b05671 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ScaleFloatFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs index 4131649e17..6e219b238c 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/ShortFieldSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using System; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs index 0fc2a9442b..8c233b1f27 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SimpleBoolFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs index bf0a48ce1f..3f3da4dae7 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SimpleFloatFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs index 5de2beb110..a06fd4ae52 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SingleFunction.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Search; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Search; using System; using System.Collections; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs index befdae8edf..cdb9915945 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SumFloatFunction.cs @@ -1,4 +1,6 @@ -namespace Lucene.Net.Queries.Function.ValueSources +// Lucene version compatibility level 4.8.1 + +namespace Lucene.Net.Queries.Function.ValueSources { /* * Licensed to the Apache Software Foundation (ASF) under one or more diff --git a/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs index 60c72a2bcb..c02d255d1b 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/SumTotalTermFreqValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using System; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs index 000403bc4e..d1173d23fe 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Search.Similarities; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs index 64fec7858e..39d217bc6c 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs index 38d6213d7c..6c7200d6d4 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries.Function.DocValues; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs index 3417447b02..5f5ca5cf11 100644 --- a/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs +++ b/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using System.Collections; using System.Collections.Generic; diff --git a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs index fab5b4ed3d..c4c5c0bf3a 100644 --- a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs +++ b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs @@ -1,4 +1,5 @@ -using J2N.Collections.Generic.Extensions; +// Lucene version compatibility level 4.8.1 +using J2N.Collections.Generic.Extensions; using Lucene.Net.Analysis; using Lucene.Net.Analysis.TokenAttributes; using Lucene.Net.Documents; diff --git a/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs b/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs index 337c77ee4b..b741d43b93 100644 --- a/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs +++ b/src/Lucene.Net.Queries/Mlt/MoreLikeThisQuery.cs @@ -1,4 +1,5 @@ -/* +// Lucene version compatibility level 4.8.1 +/* * Created on 25-Jan-2006 */ using Lucene.Net.Analysis; diff --git a/src/Lucene.Net.Queries/TermFilter.cs b/src/Lucene.Net.Queries/TermFilter.cs index 9217e5f41e..f8f1c1e848 100644 --- a/src/Lucene.Net.Queries/TermFilter.cs +++ b/src/Lucene.Net.Queries/TermFilter.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Util; using System; diff --git a/src/Lucene.Net.Queries/TermsFilter.cs b/src/Lucene.Net.Queries/TermsFilter.cs index 960b894f87..c0f9c91b05 100644 --- a/src/Lucene.Net.Queries/TermsFilter.cs +++ b/src/Lucene.Net.Queries/TermsFilter.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Search; using Lucene.Net.Support; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs b/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs index b4159a50c7..6a80a345a0 100644 --- a/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/BooleanFilterTest.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Analysis; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Queries; @@ -42,6 +43,7 @@ public override void SetUp() #endif Random, directory, new MockAnalyzer(Random, MockTokenizer.WHITESPACE, false)); + //Add series of docs with filterable fields : acces rights, prices, dates and "in-stock" flags AddDoc(writer, @"admin guest", @"010", @"20040101", @"Y"); AddDoc(writer, @"guest", @"020", @"20040101", @"Y"); AddDoc(writer, @"guest", @"020", @"20050101", @"Y"); @@ -87,23 +89,23 @@ private Filter GetWrappedTermQuery(string field, string text) private Filter GetEmptyFilter() { - return new AnonymousFilter(); + return new FilterAnonymousClass(); } - private sealed class AnonymousFilter : Filter + private sealed class FilterAnonymousClass : Filter { public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { - return new FixedBitSet(context.AtomicReader.MaxDoc); + return new FixedBitSet(context.Reader.MaxDoc); } } private Filter GetNullDISFilter() { - return new AnonymousFilter1(); + return new FilterAnonymousClass1(); } - private sealed class AnonymousFilter1 : Filter + private sealed class FilterAnonymousClass1 : Filter { public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { @@ -113,10 +115,10 @@ public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDo private Filter GetNullDISIFilter() { - return new AnonymousFilter2(); + return new FilterAnonymousClass2(); } - private sealed class AnonymousDocIdSet : DocIdSet + private sealed class DocIdSetAnonymousClass : DocIdSet { public override DocIdSetIterator GetIterator() { @@ -126,11 +128,11 @@ public override DocIdSetIterator GetIterator() public override bool IsCacheable => true; } - private sealed class AnonymousFilter2 : Filter + private sealed class FilterAnonymousClass2 : Filter { public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { - return new AnonymousDocIdSet(); + return new DocIdSetAnonymousClass(); } } @@ -156,6 +158,8 @@ public void TestShould() BooleanFilter booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.SHOULD); TstFilterCard(@"Should retrieves only 1 doc", 1, booleanFilter); + + // same with a real DISI (no OpenBitSetIterator) booleanFilter = new BooleanFilter(); booleanFilter.Add(GetWrappedTermQuery(@"price", @"030"), Occur.SHOULD); TstFilterCard(@"Should retrieves only 1 doc", 1, booleanFilter); @@ -178,13 +182,17 @@ public void TestShouldsAndMustNot() booleanFilter.Add(GetRangeFilter(@"price", @"020", @"030"), Occur.SHOULD); booleanFilter.Add(GetTermsFilter(@"inStock", @"N"), Occur.MUST_NOT); TstFilterCard(@"Shoulds Ored but AndNot", 4, booleanFilter); + booleanFilter.Add(GetTermsFilter(@"inStock", @"Maybe"), Occur.MUST_NOT); TstFilterCard(@"Shoulds Ored but AndNots", 3, booleanFilter); + + // same with a real DISI (no OpenBitSetIterator) booleanFilter = new BooleanFilter(); booleanFilter.Add(GetRangeFilter(@"price", @"010", @"020"), Occur.SHOULD); booleanFilter.Add(GetRangeFilter(@"price", @"020", @"030"), Occur.SHOULD); booleanFilter.Add(GetWrappedTermQuery(@"inStock", @"N"), Occur.MUST_NOT); TstFilterCard(@"Shoulds Ored but AndNot", 4, booleanFilter); + booleanFilter.Add(GetWrappedTermQuery(@"inStock", @"Maybe"), Occur.MUST_NOT); TstFilterCard(@"Shoulds Ored but AndNots", 3, booleanFilter); } @@ -197,6 +205,8 @@ public void TestShouldsAndMust() booleanFilter.Add(GetRangeFilter(@"price", @"020", @"030"), Occur.SHOULD); booleanFilter.Add(GetTermsFilter(@"accessRights", @"admin"), Occur.MUST); TstFilterCard(@"Shoulds Ored but MUST", 3, booleanFilter); + + // same with a real DISI (no OpenBitSetIterator) booleanFilter = new BooleanFilter(); booleanFilter.Add(GetRangeFilter(@"price", @"010", @"020"), Occur.SHOULD); booleanFilter.Add(GetRangeFilter(@"price", @"020", @"030"), Occur.SHOULD); @@ -224,6 +234,8 @@ public void TestShouldsAndMustsAndMustNot() booleanFilter.Add(GetRangeFilter(@"date", @"20050101", @"20051231"), Occur.MUST); booleanFilter.Add(GetTermsFilter(@"inStock", @"N"), Occur.MUST_NOT); TstFilterCard(@"Shoulds Ored but MUSTs ANDED and MustNot", 0, booleanFilter); + + // same with a real DISI (no OpenBitSetIterator) booleanFilter = new BooleanFilter(); booleanFilter.Add(GetRangeFilter(@"price", @"030", @"040"), Occur.SHOULD); booleanFilter.Add(GetWrappedTermQuery(@"accessRights", @"admin"), Occur.MUST); @@ -238,6 +250,8 @@ public void TestJustMust() BooleanFilter booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"accessRights", @"admin"), Occur.MUST); TstFilterCard(@"MUST", 3, booleanFilter); + + // same with a real DISI (no OpenBitSetIterator) booleanFilter = new BooleanFilter(); booleanFilter.Add(GetWrappedTermQuery(@"accessRights", @"admin"), Occur.MUST); TstFilterCard(@"MUST", 3, booleanFilter); @@ -249,6 +263,8 @@ public void TestJustMustNot() BooleanFilter booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"inStock", @"N"), Occur.MUST_NOT); TstFilterCard(@"MUST_NOT", 4, booleanFilter); + + // same with a real DISI (no OpenBitSetIterator) booleanFilter = new BooleanFilter(); booleanFilter.Add(GetWrappedTermQuery(@"inStock", @"N"), Occur.MUST_NOT); TstFilterCard(@"MUST_NOT", 4, booleanFilter); @@ -261,6 +277,8 @@ public void TestMustAndMustNot() booleanFilter.Add(GetTermsFilter(@"inStock", @"N"), Occur.MUST); booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.MUST_NOT); TstFilterCard(@"MUST_NOT wins over MUST for same docs", 0, booleanFilter); + + // same with a real DISI (no OpenBitSetIterator) booleanFilter = new BooleanFilter(); booleanFilter.Add(GetWrappedTermQuery(@"inStock", @"N"), Occur.MUST); booleanFilter.Add(GetWrappedTermQuery(@"price", @"030"), Occur.MUST_NOT); @@ -281,22 +299,27 @@ public void TestCombinedNullDocIdSets() booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.MUST); booleanFilter.Add(GetNullDISFilter(), Occur.MUST); TstFilterCard(@"A MUST filter that returns a null DIS should never return documents", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.MUST); booleanFilter.Add(GetNullDISIFilter(), Occur.MUST); TstFilterCard(@"A MUST filter that returns a null DISI should never return documents", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.SHOULD); booleanFilter.Add(GetNullDISFilter(), Occur.SHOULD); TstFilterCard(@"A SHOULD filter that returns a null DIS should be invisible", 1, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.SHOULD); booleanFilter.Add(GetNullDISIFilter(), Occur.SHOULD); TstFilterCard(@"A SHOULD filter that returns a null DISI should be invisible", 1, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.MUST); booleanFilter.Add(GetNullDISFilter(), Occur.MUST_NOT); TstFilterCard(@"A MUST_NOT filter that returns a null DIS should be invisible", 1, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"price", @"030"), Occur.MUST); booleanFilter.Add(GetNullDISIFilter(), Occur.MUST_NOT); @@ -309,18 +332,23 @@ public void TestJustNullDocIdSets() BooleanFilter booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISFilter(), Occur.MUST); TstFilterCard(@"A MUST filter that returns a null DIS should never return documents", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISIFilter(), Occur.MUST); TstFilterCard(@"A MUST filter that returns a null DISI should never return documents", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISFilter(), Occur.SHOULD); TstFilterCard(@"A single SHOULD filter that returns a null DIS should never return documents", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISIFilter(), Occur.SHOULD); TstFilterCard(@"A single SHOULD filter that returns a null DISI should never return documents", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISFilter(), Occur.MUST_NOT); TstFilterCard(@"A single MUST_NOT filter that returns a null DIS should be invisible", 5, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISIFilter(), Occur.MUST_NOT); TstFilterCard(@"A single MUST_NOT filter that returns a null DIS should be invisible", 5, booleanFilter); @@ -333,10 +361,12 @@ public void TestNonMatchingShouldsAndMusts() booleanFilter.Add(GetEmptyFilter(), Occur.SHOULD); booleanFilter.Add(GetTermsFilter(@"accessRights", @"admin"), Occur.MUST); TstFilterCard(@">0 shoulds with no matches should return no docs", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISFilter(), Occur.SHOULD); booleanFilter.Add(GetTermsFilter(@"accessRights", @"admin"), Occur.MUST); TstFilterCard(@">0 shoulds with no matches should return no docs", 0, booleanFilter); + booleanFilter = new BooleanFilter(); booleanFilter.Add(GetNullDISIFilter(), Occur.SHOULD); booleanFilter.Add(GetTermsFilter(@"accessRights", @"admin"), Occur.MUST); @@ -349,6 +379,7 @@ public void TestToStringOfBooleanFilterContainingTermsFilter() BooleanFilter booleanFilter = new BooleanFilter(); booleanFilter.Add(GetTermsFilter(@"inStock", @"N"), Occur.MUST); booleanFilter.Add(GetTermsFilter(@"isFragile", @"Y"), Occur.MUST); + assertEquals(@"BooleanFilter(+inStock:N +isFragile:Y)", booleanFilter.ToString()); } @@ -356,14 +387,19 @@ public void TestToStringOfBooleanFilterContainingTermsFilter() public void TestToStringOfWrappedBooleanFilters() { BooleanFilter orFilter = new BooleanFilter(); + BooleanFilter stockFilter = new BooleanFilter(); stockFilter.Add(new FilterClause(GetTermsFilter(@"inStock", @"Y"), Occur.MUST)); stockFilter.Add(new FilterClause(GetTermsFilter(@"barCode", @"12345678"), Occur.MUST)); + orFilter.Add(new FilterClause(stockFilter, Occur.SHOULD)); + BooleanFilter productPropertyFilter = new BooleanFilter(); productPropertyFilter.Add(new FilterClause(GetTermsFilter(@"isHeavy", @"N"), Occur.MUST)); productPropertyFilter.Add(new FilterClause(GetTermsFilter(@"isDamaged", @"Y"), Occur.MUST)); + orFilter.Add(new FilterClause(productPropertyFilter, Occur.SHOULD)); + BooleanFilter composedFilter = new BooleanFilter(); composedFilter.Add(new FilterClause(orFilter, Occur.MUST)); assertEquals(@"BooleanFilter(+BooleanFilter(BooleanFilter(+inStock:Y +barCode:12345678) BooleanFilter(+isHeavy:N +isDamaged:Y)))", composedFilter.ToString()); diff --git a/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs b/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs index d890a26bbf..56231d758b 100644 --- a/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs +++ b/src/Lucene.Net.Tests.Queries/BoostingQueryTest.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Index; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Index; using Lucene.Net.Queries; using Lucene.Net.Search; using Lucene.Net.Util; diff --git a/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs b/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs index 5564420fba..6290fb4132 100644 --- a/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/ChainedFilterTest.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using System.Globalization; using Lucene.Net.Documents; using Lucene.Net.Index; @@ -81,8 +82,10 @@ public override void SetUp() // just treat dates as strings and select the whole range for now... dateFilter = TermRangeFilter.NewStringRange("date", "", "ZZZZ", true, true); - bobFilter = new QueryWrapperFilter(new TermQuery(new Term("owner", "bob"))); - sueFilter = new QueryWrapperFilter(new TermQuery(new Term("owner", "sue"))); + bobFilter = new QueryWrapperFilter( + new TermQuery(new Term("owner", "bob"))); + sueFilter = new QueryWrapperFilter( + new TermQuery(new Term("owner", "sue"))); } [TearDown] @@ -136,7 +139,8 @@ public virtual void TestSingleFilter() [Test] public virtual void TestOR() { - ChainedFilter chain = GetChainedFilter(new Filter[] { sueFilter, bobFilter }, null); + ChainedFilter chain = GetChainedFilter( + new Filter[] { sueFilter, bobFilter }, null); int numHits = searcher.Search(query, chain, 1000).TotalHits; assertEquals("OR matches all", Max, numHits); @@ -145,7 +149,8 @@ public virtual void TestOR() [Test] public virtual void TestAND() { - ChainedFilter chain = GetChainedFilter(new Filter[] { dateFilter, bobFilter }, ChainedFilter.AND); + ChainedFilter chain = GetChainedFilter( + new Filter[] { dateFilter, bobFilter }, ChainedFilter.AND); TopDocs hits = searcher.Search(query, chain, 1000); assertEquals("AND matches just bob", Max / 2, hits.TotalHits); @@ -155,7 +160,8 @@ public virtual void TestAND() [Test] public virtual void TestXOR() { - ChainedFilter chain = GetChainedFilter(new Filter[] { dateFilter, bobFilter }, ChainedFilter.XOR); + ChainedFilter chain = GetChainedFilter( + new Filter[] { dateFilter, bobFilter }, ChainedFilter.XOR); TopDocs hits = searcher.Search(query, chain, 1000); assertEquals("XOR matches sue", Max / 2, hits.TotalHits); @@ -165,7 +171,8 @@ public virtual void TestXOR() [Test] public virtual void TestANDNOT() { - ChainedFilter chain = GetChainedFilter(new Filter[] { dateFilter, sueFilter }, new int[] { ChainedFilter.AND, ChainedFilter.ANDNOT }); + ChainedFilter chain = GetChainedFilter( + new Filter[] { dateFilter, sueFilter }, new int[] { ChainedFilter.AND, ChainedFilter.ANDNOT }); TopDocs hits = searcher.Search(query, chain, 1000); assertEquals("ANDNOT matches just bob", Max / 2, hits.TotalHits); diff --git a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs index ddaf36f367..822530ec33 100644 --- a/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs +++ b/src/Lucene.Net.Tests.Queries/CommonTermsQueryTest.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using System.Collections.Generic; using Lucene.Net.Analysis; using Lucene.Net.Documents; @@ -43,7 +44,8 @@ public void TestBasics() Random, dir, analyzer); var docs = new string[] { - @"this is the end of the world right", @"is this it or maybe not", + @"this is the end of the world right", + @"is this it or maybe not", @"this is the end of the universe as we know it", @"there is the famous restaurant at the end of the universe" }; @@ -59,7 +61,7 @@ public void TestBasics() IndexReader r = w.GetReader(); IndexSearcher s = NewSearcher(r); { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); @@ -73,8 +75,8 @@ public void TestBasics() assertEquals(@"3", r.Document(search.ScoreDocs[2].Doc).Get(@"id")); } - { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + { // only high freq + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); @@ -84,21 +86,23 @@ public void TestBasics() assertEquals(@"2", r.Document(search.ScoreDocs[1].Doc).Get(@"id")); } - { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.MUST, Random.NextBoolean() ? 2F : 0.5F); + { // low freq is mandatory + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.MUST, Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); query.Add(new Term("field", "world")); + TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 1); assertEquals(@"0", r.Document(search.ScoreDocs[0].Doc).Get(@"id")); } - { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.MUST, Random.NextBoolean() ? 2F : 0.5F); + { // low freq is mandatory + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.MUST, Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "restaurant")); query.Add(new Term("field", "universe")); + TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 1); assertEquals(@"3", r.Document(search.ScoreDocs[0].Doc).Get(@"id")); @@ -112,33 +116,40 @@ public void TestBasics() [Test] public void TestEqualsHashCode() { - CommonTermsQuery query = new CommonTermsQuery(RandomOccur(Random), RandomOccur(Random), Random.NextSingle(), Random.NextBoolean()); + CommonTermsQuery query = new CommonTermsQuery(RandomOccur(Random), + RandomOccur(Random), Random.NextSingle(), Random.NextBoolean()); int terms = AtLeast(2); for (int i = 0; i < terms; i++) { - query.Add(new Term(TestUtil.RandomRealisticUnicodeString(Random), TestUtil.RandomRealisticUnicodeString(Random))); + query.Add(new Term(TestUtil.RandomRealisticUnicodeString(Random), + TestUtil.RandomRealisticUnicodeString(Random))); } QueryUtils.CheckHashEquals(query); - QueryUtils.CheckUnequal(new CommonTermsQuery(RandomOccur(Random), RandomOccur(Random), Random.NextSingle(), Random.NextBoolean()), query); + QueryUtils.CheckUnequal(new CommonTermsQuery(RandomOccur(Random), + RandomOccur(Random), Random.NextSingle(), Random.NextBoolean()), query); { long seed = Random.NextInt64(); Random r = new Random((int)seed); - CommonTermsQuery left = new CommonTermsQuery(RandomOccur(r), RandomOccur(r), r.NextSingle(), r.NextBoolean()); + CommonTermsQuery left = new CommonTermsQuery(RandomOccur(r), + RandomOccur(r), r.NextSingle(), r.NextBoolean()); int leftTerms = AtLeast(r, 2); for (int i = 0; i < leftTerms; i++) { - left.Add(new Term(TestUtil.RandomRealisticUnicodeString(r), TestUtil.RandomRealisticUnicodeString(r))); + left.Add(new Term(TestUtil.RandomRealisticUnicodeString(r), + TestUtil.RandomRealisticUnicodeString(r))); } left.HighFreqMinimumNumberShouldMatch = r.nextInt(4); left.LowFreqMinimumNumberShouldMatch = r.nextInt(4); r = new Random((int)seed); - CommonTermsQuery right = new CommonTermsQuery(RandomOccur(r), RandomOccur(r), r.NextSingle(), r.NextBoolean()); + CommonTermsQuery right = new CommonTermsQuery(RandomOccur(r), + RandomOccur(r), r.NextSingle(), r.NextBoolean()); int rightTerms = AtLeast(r, 2); for (int i = 0; i < rightTerms; i++) { - right.Add(new Term(TestUtil.RandomRealisticUnicodeString(r), TestUtil.RandomRealisticUnicodeString(r))); + right.Add(new Term(TestUtil.RandomRealisticUnicodeString(r), + TestUtil.RandomRealisticUnicodeString(r))); } right.HighFreqMinimumNumberShouldMatch = r.nextInt(4); @@ -156,7 +167,8 @@ private static Occur RandomOccur(Random random) public void TestNullTerm() { Random random = Random; - CommonTermsQuery query = new CommonTermsQuery(RandomOccur(random), RandomOccur(random), Random.NextSingle()); + CommonTermsQuery query = new CommonTermsQuery(RandomOccur(random), + RandomOccur(random), Random.NextSingle()); try { query.Add(null); @@ -181,7 +193,8 @@ public void TestMinShouldMatch() Random, dir, analyzer); string[] docs = new string[] { - @"this is the end of the world right", @"is this it or maybe not", + @"this is the end of the world right", + @"is this it or maybe not", @"this is the end of the universe as we know it", @"there is the famous restaurant at the end of the universe" }; @@ -197,42 +210,45 @@ public void TestMinShouldMatch() IndexReader r = w.GetReader(); IndexSearcher s = NewSearcher(r); { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); query.Add(new Term("field", "world")); query.Add(new Term("field", "universe")); query.Add(new Term("field", "right")); - query.LowFreqMinimumNumberShouldMatch = 0.5F; + query.LowFreqMinimumNumberShouldMatch = 0.5f; TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 1); assertEquals(@"0", r.Document(search.ScoreDocs[0].Doc).Get(@"id")); } { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); query.Add(new Term("field", "world")); query.Add(new Term("field", "universe")); query.Add(new Term("field", "right")); - query.LowFreqMinimumNumberShouldMatch = 2F; + query.LowFreqMinimumNumberShouldMatch = 2.0f; TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 1); assertEquals(@"0", r.Document(search.ScoreDocs[0].Doc).Get(@"id")); } { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); query.Add(new Term("field", "world")); query.Add(new Term("field", "universe")); query.Add(new Term("field", "right")); - query.LowFreqMinimumNumberShouldMatch = 0.49F; + query.LowFreqMinimumNumberShouldMatch = 0.49f; TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 3); assertEquals(@"0", r.Document(search.ScoreDocs[0].Doc).Get(@"id")); @@ -241,14 +257,15 @@ public void TestMinShouldMatch() } { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); query.Add(new Term("field", "world")); query.Add(new Term("field", "universe")); query.Add(new Term("field", "right")); - query.LowFreqMinimumNumberShouldMatch = 1F; + query.LowFreqMinimumNumberShouldMatch = 1.0f; TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 3); assertEquals(@"0", r.Document(search.ScoreDocs[0].Doc).Get(@"id")); @@ -258,48 +275,58 @@ public void TestMinShouldMatch() } { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); query.Add(new Term("field", "world")); query.Add(new Term("field", "universe")); query.Add(new Term("field", "right")); - query.LowFreqMinimumNumberShouldMatch = 1F; - query.HighFreqMinimumNumberShouldMatch = 4F; + query.LowFreqMinimumNumberShouldMatch = 1.0f; + query.HighFreqMinimumNumberShouldMatch = 4.0f; TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 3); - assertEquals(search.ScoreDocs[1].Score, search.ScoreDocs[2].Score, 0F); + assertEquals(search.ScoreDocs[1].Score, search.ScoreDocs[2].Score, 0.0f); assertEquals(@"0", r.Document(search.ScoreDocs[0].Doc).Get(@"id")); + // doc 2 and 3 only get a score from low freq terms assertEquals( new JCG.HashSet { @"2", @"3" }, - new JCG.HashSet { r.Document(search.ScoreDocs[1].Doc).Get(@"id"), r.Document(search.ScoreDocs[2].Doc).Get(@"id") }, + new JCG.HashSet { + r.Document(search.ScoreDocs[1].Doc).Get(@"id"), + r.Document(search.ScoreDocs[2].Doc).Get(@"id") }, aggressive: false); } { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + // only high freq terms around - check that min should match is applied + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "the")); - query.LowFreqMinimumNumberShouldMatch = 1F; - query.HighFreqMinimumNumberShouldMatch = 2F; + query.LowFreqMinimumNumberShouldMatch = 1.0f; + query.HighFreqMinimumNumberShouldMatch = 2.0f; TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 4); } { - CommonTermsQuery query = new CommonTermsQuery(Occur.MUST, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + // only high freq terms around - check that min should match is applied + CommonTermsQuery query = new CommonTermsQuery(Occur.MUST, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "the")); - query.LowFreqMinimumNumberShouldMatch = 1F; - query.HighFreqMinimumNumberShouldMatch = 2F; + query.LowFreqMinimumNumberShouldMatch = 1.0f; + query.HighFreqMinimumNumberShouldMatch = 2.0f; TopDocs search = s.Search(query, 10); assertEquals(search.TotalHits, 2); assertEquals( new JCG.HashSet { @"0", @"2" }, - new JCG.HashSet { r.Document(search.ScoreDocs[0].Doc).Get(@"id"), r.Document(search.ScoreDocs[1].Doc).Get(@"id") }, + new JCG.HashSet { + r.Document(search.ScoreDocs[0].Doc).Get(@"id"), + r.Document(search.ScoreDocs[1].Doc).Get(@"id") }, aggressive: false); } @@ -347,11 +374,11 @@ public void TestExtend() Random, dir, analyzer); var docs = new string[] { - @"this is the end of the world right", @"is this it or maybe not", + @"this is the end of the world right", + @"is this it or maybe not", @"this is the end of the universe as we know it", @"there is the famous restaurant at the end of the universe" }; - for (int i = 0; i < docs.Length; i++) { Document doc = new Document(); @@ -363,7 +390,8 @@ public void TestExtend() IndexReader r = w.GetReader(); IndexSearcher s = NewSearcher(r); { - CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + CommonTermsQuery query = new CommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); @@ -378,7 +406,9 @@ public void TestExtend() } { - CommonTermsQuery query = new ExtendedCommonTermsQuery(Occur.SHOULD, Occur.SHOULD, Random.NextBoolean() ? 2F : 0.5F); + // this one boosts the termQuery("field" "universe") by 10x + CommonTermsQuery query = new ExtendedCommonTermsQuery(Occur.SHOULD, Occur.SHOULD, + Random.NextBoolean() ? 2.0f : 0.5f); query.Add(new Term("field", "is")); query.Add(new Term("field", "this")); query.Add(new Term("field", "end")); @@ -413,8 +443,8 @@ public void TestRandomIndex() AtomicReader wrapper = SlowCompositeReaderWrapper.Wrap(reader); string field = @"body"; Terms terms = wrapper.GetTerms(field); - var lowFreqQueue = new AnonymousPriorityQueue(5); - Util.PriorityQueue highFreqQueue = new AnonymousPriorityQueue1(5); + var lowFreqQueue = new PriorityQueueAnonymousClass(5); + var highFreqQueue = new PriorityQueueAnonymousClass1(5); try { TermsEnum iterator = terms.GetEnumerator(); @@ -422,8 +452,10 @@ public void TestRandomIndex() { if (highFreqQueue.Count < 5) { - highFreqQueue.Add(new TermAndFreq(BytesRef.DeepCopyOf(iterator.Term), iterator.DocFreq)); - lowFreqQueue.Add(new TermAndFreq(BytesRef.DeepCopyOf(iterator.Term), iterator.DocFreq)); + highFreqQueue.Add(new TermAndFreq( + BytesRef.DeepCopyOf(iterator.Term), iterator.DocFreq)); + lowFreqQueue.Add(new TermAndFreq( + BytesRef.DeepCopyOf(iterator.Term), iterator.DocFreq)); } else { @@ -448,22 +480,25 @@ public void TestRandomIndex() AssumeTrue(@"unlucky index", highFreq - 1 > lowFreq); List highTerms = QueueToList(highFreqQueue); List lowTerms = QueueToList(lowFreqQueue); + IndexSearcher searcher = NewSearcher(reader); Occur lowFreqOccur = RandomOccur(Random); BooleanQuery verifyQuery = new BooleanQuery(); - CommonTermsQuery cq = new CommonTermsQuery(RandomOccur(Random), lowFreqOccur, highFreq - 1, Random.NextBoolean()); + CommonTermsQuery cq = new CommonTermsQuery(RandomOccur(Random), + lowFreqOccur, highFreq - 1, Random.NextBoolean()); foreach (TermAndFreq termAndFreq in lowTerms) { cq.Add(new Term(field, termAndFreq.term)); - verifyQuery.Add(new BooleanClause(new TermQuery(new Term(field, termAndFreq.term)), lowFreqOccur)); + verifyQuery.Add(new BooleanClause(new TermQuery(new Term(field, + termAndFreq.term)), lowFreqOccur)); } - foreach (TermAndFreq termAndFreq in highTerms) { cq.Add(new Term(field, termAndFreq.term)); } TopDocs cqSearch = searcher.Search(cq, reader.MaxDoc); + TopDocs verifySearch = searcher.Search(verifyQuery, reader.MaxDoc); assertEquals(verifySearch.TotalHits, cqSearch.TotalHits); var hits = new JCG.HashSet(); @@ -478,6 +513,13 @@ public void TestRandomIndex() } assertTrue(hits.Count == 0); + + /* + * need to force merge here since QueryUtils adds checks based + * on leave readers which have different statistics than the top + * level reader if we have more than one segment. This could + * result in a different query / results. + */ w.ForceMerge(1); DirectoryReader reader2 = w.GetReader(); QueryUtils.Check( @@ -496,9 +538,9 @@ public void TestRandomIndex() } } - private sealed class AnonymousPriorityQueue : Util.PriorityQueue + private sealed class PriorityQueueAnonymousClass : Util.PriorityQueue { - public AnonymousPriorityQueue(int maxSize) + public PriorityQueueAnonymousClass(int maxSize) : base(maxSize) { } @@ -509,9 +551,9 @@ protected internal override bool LessThan(TermAndFreq a, TermAndFreq b) } } - private sealed class AnonymousPriorityQueue1 : Util.PriorityQueue + private sealed class PriorityQueueAnonymousClass1 : Util.PriorityQueue { - public AnonymousPriorityQueue1(int maxSize) + public PriorityQueueAnonymousClass1(int maxSize) : base(maxSize) { } @@ -550,11 +592,19 @@ public int CompareTo(TermAndFreq other) } } + /// + /// populates a writer with random stuff. this must be fully reproducable with + /// the seed! + /// public static void CreateRandomIndex(int numdocs, RandomIndexWriter writer, long seed) { Random random = new Random((int)seed); // primary source for our data is from linefiledocs, its realistic. LineFileDocs lineFileDocs = new LineFileDocs(random, false); // no docvalues in 4x + + // TODO: we should add other fields that use things like docs&freqs but omit + // positions, + // because linefiledocs doesn't cover all the possibilities. for (int i = 0; i < numdocs; i++) { writer.AddDocument(lineFileDocs.NextDoc()); @@ -575,7 +625,7 @@ protected override Query NewTermQuery(Term term, TermContext context) Query query = base.NewTermQuery(term, context); if (term.Text().Equals(@"universe", StringComparison.Ordinal)) { - query.Boost = 100F; + query.Boost = 100f; } return query; diff --git a/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs b/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs index e4f3737948..c445a72de5 100644 --- a/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs +++ b/src/Lucene.Net.Tests.Queries/Function/FunctionTestSetup.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; @@ -39,22 +40,22 @@ public abstract class FunctionTestSetup : LuceneTestCase /// Actual score computation order is slightly different than assumptios /// this allows for a small amount of variation /// - protected internal static float TEST_SCORE_TOLERANCE_DELTA = 0.001f; + protected const float TEST_SCORE_TOLERANCE_DELTA = 0.001f; - protected internal const int N_DOCS = 17; // select a primary number > 2 + protected const int N_DOCS = 17; // select a primary number > 2 - protected internal const string ID_FIELD = "id"; - protected internal const string TEXT_FIELD = "text"; - protected internal const string INT_FIELD = "iii"; - protected internal const string FLOAT_FIELD = "fff"; + protected const string ID_FIELD = "id"; + protected const string TEXT_FIELD = "text"; + protected const string INT_FIELD = "iii"; + protected const string FLOAT_FIELD = "fff"; #pragma warning disable 612, 618 - protected internal ValueSource BYTE_VALUESOURCE = new ByteFieldSource(INT_FIELD); - protected internal ValueSource SHORT_VALUESOURCE = new Int16FieldSource(INT_FIELD); + protected ValueSource BYTE_VALUESOURCE = new ByteFieldSource(INT_FIELD); + protected ValueSource SHORT_VALUESOURCE = new Int16FieldSource(INT_FIELD); #pragma warning restore 612, 618 - protected internal ValueSource INT_VALUESOURCE = new Int32FieldSource(INT_FIELD); - protected internal ValueSource INT_AS_FLOAT_VALUESOURCE = new SingleFieldSource(INT_FIELD); - protected internal ValueSource FLOAT_VALUESOURCE = new SingleFieldSource(FLOAT_FIELD); + protected ValueSource INT_VALUESOURCE = new Int32FieldSource(INT_FIELD); + protected ValueSource INT_AS_FLOAT_VALUESOURCE = new SingleFieldSource(INT_FIELD); + protected ValueSource FLOAT_VALUESOURCE = new SingleFieldSource(FLOAT_FIELD); private static readonly string[] DOC_TEXT_LINES = { @@ -74,8 +75,8 @@ public abstract class FunctionTestSetup : LuceneTestCase "text for the test, but oh much much safer. " }; - protected internal static Directory dir; - protected internal static Analyzer anlzr; + protected static Directory dir; + protected static Analyzer anlzr; [TearDown] public override void TearDown() @@ -135,11 +136,7 @@ protected internal void CreateIndex(bool doMultiSegment) } } - /// - /// LUCENENET specific - /// Non-static because NewField is now non-static - /// - private void AddDoc(RandomIndexWriter iw, int i) + private static void AddDoc(RandomIndexWriter iw, int i) { Document d = new Document(); Field f; @@ -168,7 +165,7 @@ private void AddDoc(RandomIndexWriter iw, int i) } // 17 --> ID00017 - protected internal static string Id2String(int scoreAndID) + protected static string Id2String(int scoreAndID) { string s = "000000000" + scoreAndID; int n = ("" + N_DOCS).Length + 3; @@ -183,13 +180,13 @@ private static string TextLine(int docNum) } // extract expected doc score from its ID Field: "ID7" --> 7.0 - protected internal static float ExpectedFieldScore(string docIDFieldVal) + protected static float ExpectedFieldScore(string docIDFieldVal) { return Convert.ToSingle(docIDFieldVal.Substring(2)); } // debug messages (change DBG to true for anything to print) - protected internal static void Log(object o) + protected static void Log(object o) { if (Verbose) { diff --git a/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs b/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs index dc82e186c4..70caf92843 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestBoostedQuery.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Analysis; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Index.Extensions; diff --git a/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs b/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs index cf27cbd1ef..9afd78019d 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestDocValuesFieldSources.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Analysis; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Queries.Function; diff --git a/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs b/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs index bdb2e6ba4f..4cb8df9fd0 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestFieldScoreQuery.cs @@ -1,4 +1,5 @@ -using J2N.Text; +// Lucene version compatibility level 4.8.1 +using J2N.Text; using Lucene.Net.Index; using Lucene.Net.Queries.Function; using Lucene.Net.Search; diff --git a/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs b/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs index 768dd6f2cf..13848daf73 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestFunctionQuerySort.cs @@ -1,4 +1,6 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; +using System.Globalization; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Index.Extensions; @@ -48,7 +50,7 @@ public void TestSearchAfterWhenSortingByFunctionValues() const int NUM_VALS = 5; for (int val = NUM_VALS; val > 0; val--) { - field.SetStringValue(Convert.ToString(val)); + field.SetStringValue(Convert.ToString(val, CultureInfo.InvariantCulture)); writer.AddDocument(doc); } @@ -87,7 +89,7 @@ public void TestSearchAfterWhenSortingByFunctionValues() int afterValue = (int)((double?)afterHit.Fields[0]); foreach (ScoreDoc hit in hits.ScoreDocs) { - int val = Convert.ToInt32(reader.Document(hit.Doc).Get("value")); + int val = Convert.ToInt32(reader.Document(hit.Doc).Get("value"), CultureInfo.InvariantCulture); assertTrue(afterValue <= val); assertFalse(hit.Doc == afterHit.Doc); } diff --git a/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs b/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs index 753d06fd4e..19ff987174 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestLongNormValueSource.cs @@ -1,4 +1,5 @@ -using Lucene.Net.Analysis; +// Lucene version compatibility level 4.8.1 +using Lucene.Net.Analysis; using Lucene.Net.Documents; using Lucene.Net.Index; using Lucene.Net.Index.Extensions; @@ -81,7 +82,9 @@ public void TestNorm() { // no norm field (so agnostic to indexed similarity) searcher.Similarity = sim; - AssertHits(new FunctionQuery(new NormValueSource("text")), new float[] { 0f, 0f }); + AssertHits(new FunctionQuery( + new NormValueSource("text")), + new float[] { 0f, 0f }); } finally { @@ -89,7 +92,7 @@ public void TestNorm() } } - protected virtual void AssertHits(Query q, float[] scores) + internal void AssertHits(Query q, float[] scores) { ScoreDoc[] expected = new ScoreDoc[scores.Length]; int[] expectedDocs = new int[scores.Length]; diff --git a/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs b/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs index ef5c41b765..baadaa5683 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestOrdValues.cs @@ -1,4 +1,5 @@ -using J2N.Text; +// Lucene version compatibility level 4.8.1 +using J2N.Text; using Lucene.Net.Index; using Lucene.Net.Queries.Function; using Lucene.Net.Queries.Function.ValueSources; @@ -91,7 +92,9 @@ private void DoTestRank(string field, bool inOrder) Random, q, s); ScoreDoc[] h = s.Search(q, null, 1000).ScoreDocs; assertEquals("All docs should be matched!", N_DOCS, h.Length); - string prevID = inOrder ? "IE" : "IC"; // smaller than all ids of docs in this test ("ID0001", etc.) - greater than all ids of docs in this test ("ID0001", etc.) + string prevID = inOrder + ? "IE" // greater than all ids of docs in this test ("ID0001", etc.) + : "IC"; // smaller than all ids of docs in this test ("ID0001", etc.) for (int i = 0; i < h.Length; i++) { @@ -160,7 +163,9 @@ private void DoTestExactScore(string field, bool inOrder) Log(s.Explain(q, sd[i].Doc)); float expectedScore = N_DOCS - i - 1; assertEquals("score of result " + i + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA); - string expectedId = inOrder ? Id2String(N_DOCS - i) : Id2String(i + 1); // reverse ==> smaller values first - in-order ==> larger values first + string expectedId = inOrder + ? Id2String(N_DOCS - i) // in-order ==> larger values first + : Id2String(i + 1); // reverse ==> smaller values first assertTrue("id of result " + i + " shuould be " + expectedId + " != " + score, expectedId.Equals(id, StringComparison.Ordinal)); } r.Dispose(); diff --git a/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs b/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs index 96943f61ef..07a8fb7610 100644 --- a/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs +++ b/src/Lucene.Net.Tests.Queries/Function/TestValueSources.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using System.Collections.Generic; using Lucene.Net.Analysis; using Lucene.Net.Codecs; @@ -112,44 +113,53 @@ public override void TearDown() public void TestByte() { #pragma warning disable 612, 618 - AssertHits(new FunctionQuery(new ByteFieldSource("byte")), new[] { 5f, 12f }); + AssertHits(new FunctionQuery(new ByteFieldSource("byte")), + new[] { 5f, 12f }); #pragma warning restore 612, 618 } [Test] public void TestConst() { - AssertHits(new FunctionQuery(new ConstValueSource(0.3f)), new[] { 0.3f, 0.3f }); + AssertHits(new FunctionQuery(new ConstValueSource(0.3f)), + new[] { 0.3f, 0.3f }); } [Test] public void TestDiv() { - AssertHits(new FunctionQuery(new DivSingleFunction(new ConstValueSource(10f), new ConstValueSource(5f))), new[] { 2f, 2f }); + AssertHits(new FunctionQuery(new DivSingleFunction( + new ConstValueSource(10f), new ConstValueSource(5f))), + new[] { 2f, 2f }); } [Test] public void TestDocFreq() { - AssertHits(new FunctionQuery(new DocFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), new[] { 2f, 2f }); + AssertHits(new FunctionQuery( + new DocFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), + new[] { 2f, 2f }); } [Test] public void TestDoubleConst() { - AssertHits(new FunctionQuery(new DoubleConstValueSource(0.3d)), new[] { 0.3f, 0.3f }); + AssertHits(new FunctionQuery(new DoubleConstValueSource(0.3d)), + new[] { 0.3f, 0.3f }); } [Test] public void TestDouble() { - AssertHits(new FunctionQuery(new DoubleFieldSource("double")), new[] { 3.63f, 5.65f }); + AssertHits(new FunctionQuery(new DoubleFieldSource("double")), + new[] { 3.63f, 5.65f }); } [Test] public void TestFloat() { - AssertHits(new FunctionQuery(new SingleFieldSource("float")), new[] { 5.2f, 9.3f }); + AssertHits(new FunctionQuery(new SingleFieldSource("float")), + new[] { 5.2f, 9.3f }); } [Test] @@ -159,7 +169,8 @@ public void TestIDF() try { searcher.Similarity = new DefaultSimilarity(); - AssertHits(new FunctionQuery(new IDFValueSource("bogus", "bogus", "text", new BytesRef("test"))), new[] { 0.5945349f, 0.5945349f }); + AssertHits(new FunctionQuery(new IDFValueSource("bogus", "bogus", "text", new BytesRef("test"))), + new[] { 0.5945349f, 0.5945349f }); } finally { @@ -170,53 +181,70 @@ public void TestIDF() [Test] public void TestIf() { - AssertHits(new FunctionQuery(new IfFunction(new BytesRefFieldSource("id"), new ConstValueSource(1.0f), new ConstValueSource(2.0f) - )), new[] { 1f, 1f }); + AssertHits(new FunctionQuery(new IfFunction( + new BytesRefFieldSource("id"), + new ConstValueSource(1.0f), + new ConstValueSource(2.0f) + )), + new[] { 1f, 1f }); // true just if a value exists... - AssertHits(new FunctionQuery(new IfFunction(new LiteralValueSource("false"), new ConstValueSource(1.0f), new ConstValueSource(2.0f) - )), new[] { 1f, 1f }); + AssertHits(new FunctionQuery(new IfFunction( + new LiteralValueSource("false"), + new ConstValueSource(1.0f), + new ConstValueSource(2.0f) + )), + new[] { 1f, 1f }); } [Test] public void TestInt() { - AssertHits(new FunctionQuery(new Int32FieldSource("int")), new[] { 35f, 54f }); + AssertHits(new FunctionQuery(new Int32FieldSource("int")), + new[] { 35f, 54f }); } [Test] public void TestJoinDocFreq() { - AssertHits(new FunctionQuery(new JoinDocFreqValueSource("string", "text")), new[] { 2f, 0f }); + AssertHits(new FunctionQuery(new JoinDocFreqValueSource("string", "text")), + new[] { 2f, 0f }); } [Test] public void TestLinearFloat() { - AssertHits(new FunctionQuery(new LinearSingleFunction(new ConstValueSource(2.0f), 3, 1)), new[] { 7f, 7f }); + AssertHits(new FunctionQuery(new LinearSingleFunction(new ConstValueSource(2.0f), 3, 1)), + new[] { 7f, 7f }); } [Test] public void TestLong() { - AssertHits(new FunctionQuery(new Int64FieldSource("long")), new[] { 4343f, 1954f }); + AssertHits(new FunctionQuery(new Int64FieldSource("long")), + new[] { 4343f, 1954f }); } [Test] public void TestMaxDoc() { - AssertHits(new FunctionQuery(new MaxDocValueSource()), new[] { 2f, 2f }); + AssertHits(new FunctionQuery(new MaxDocValueSource()), + new[] { 2f, 2f }); } [Test] public void TestMaxFloat() { - AssertHits(new FunctionQuery(new MaxSingleFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) })), new[] { 2f, 2f }); + AssertHits(new FunctionQuery(new MaxSingleFunction(new ValueSource[] { + new ConstValueSource(1f), new ConstValueSource(2f) })), + new[] { 2f, 2f }); } [Test] public void TestMinFloat() { - AssertHits(new FunctionQuery(new MinSingleFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) })), new[] { 1f, 1f }); + AssertHits(new FunctionQuery(new MinSingleFunction(new ValueSource[] { + new ConstValueSource(1f), new ConstValueSource(2f) })), + new[] { 1f, 1f }); } [Test] @@ -227,7 +255,8 @@ public void TestNorm() { // no norm field (so agnostic to indexed similarity) searcher.Similarity = new DefaultSimilarity(); - AssertHits(new FunctionQuery(new NormValueSource("byte")), new[] { 0f, 0f }); + AssertHits(new FunctionQuery(new NormValueSource("byte")), + new[] { 0f, 0f }); } finally { @@ -238,58 +267,77 @@ public void TestNorm() [Test] public void TestNumDocs() { - AssertHits(new FunctionQuery(new NumDocsValueSource()), new[] { 2f, 2f }); + AssertHits(new FunctionQuery(new NumDocsValueSource()), + new[] { 2f, 2f }); } [Test] public void TestPow() { - AssertHits(new FunctionQuery(new PowSingleFunction(new ConstValueSource(2f), new ConstValueSource(3f))), new[] { 8f, 8f }); + AssertHits(new FunctionQuery(new PowSingleFunction( + new ConstValueSource(2f), new ConstValueSource(3f))), + new[] { 8f, 8f }); } [Test] public void TestProduct() { - AssertHits(new FunctionQuery(new ProductSingleFunction(new ValueSource[] { new ConstValueSource(2f), new ConstValueSource(3f) })), new[] { 6f, 6f }); + AssertHits(new FunctionQuery(new ProductSingleFunction( + new ValueSource[] { new ConstValueSource(2f), new ConstValueSource(3f) })), + new[] { 6f, 6f }); } [Test] public void TestQuery() { - AssertHits(new FunctionQuery(new QueryValueSource(new FunctionQuery(new ConstValueSource(2f)), 0f)), new[] { 2f, 2f }); + AssertHits(new FunctionQuery(new QueryValueSource( + new FunctionQuery(new ConstValueSource(2f)), 0f)), + new[] { 2f, 2f }); } [Test] public void TestRangeMap() { - AssertHits(new FunctionQuery(new RangeMapSingleFunction(new SingleFieldSource("float"), 5, 6, 1, 0f)), new[] { 1f, 0f }); - AssertHits(new FunctionQuery(new RangeMapSingleFunction(new SingleFieldSource("float"), 5, 6, new SumSingleFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) }), new ConstValueSource(11f))), new[] { 3f, 11f }); + AssertHits(new FunctionQuery(new RangeMapSingleFunction(new SingleFieldSource("float"), + 5, 6, 1, 0f)), + new[] { 1f, 0f }); + AssertHits(new FunctionQuery(new RangeMapSingleFunction(new SingleFieldSource("float"), + 5, 6, new SumSingleFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) }), + new ConstValueSource(11f))), + new[] { 3f, 11f }); } [Test] public void TestReciprocal() { - AssertHits(new FunctionQuery(new ReciprocalSingleFunction(new ConstValueSource(2f), 3, 1, 4)), new[] { 0.1f, 0.1f }); + AssertHits(new FunctionQuery(new ReciprocalSingleFunction(new ConstValueSource(2f), + 3, 1, 4)), + new[] { 0.1f, 0.1f }); } [Test] public void TestScale() { - AssertHits(new FunctionQuery(new ScaleSingleFunction(new Int32FieldSource("int"), 0, 1)), new[] { 0.0f, 1.0f }); + AssertHits(new FunctionQuery(new ScaleSingleFunction(new Int32FieldSource("int"), + 0, 1)), + new[] { 0.0f, 1.0f }); } [Test] public void TestShort() { #pragma warning disable 612, 618 - AssertHits(new FunctionQuery(new Int16FieldSource("short")), new[] { 945f, 123f }); + AssertHits(new FunctionQuery(new Int16FieldSource("short")), + new[] { 945f, 123f }); #pragma warning restore 612, 618 } [Test] public void TestSumFloat() { - AssertHits(new FunctionQuery(new SumSingleFunction(new ValueSource[] { new ConstValueSource(1f), new ConstValueSource(2f) })), new[] { 3f, 3f }); + AssertHits(new FunctionQuery(new SumSingleFunction(new ValueSource[] { + new ConstValueSource(1f), new ConstValueSource(2f) })), + new[] { 3f, 3f }); } [Test] @@ -297,19 +345,25 @@ public void TestSumTotalTermFreq() { if (Codec.Default.Name.Equals("Lucene3x", StringComparison.Ordinal)) { - AssertHits(new FunctionQuery(new SumTotalTermFreqValueSource("text")), new[] { -1f, -1f }); + AssertHits(new FunctionQuery(new SumTotalTermFreqValueSource("text")), + new[] { -1f, -1f }); } else { - AssertHits(new FunctionQuery(new SumTotalTermFreqValueSource("text")), new[] { 8f, 8f }); + AssertHits(new FunctionQuery(new SumTotalTermFreqValueSource("text")), + new[] { 8f, 8f }); } } [Test] public void TestTermFreq() { - AssertHits(new FunctionQuery(new TermFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), new[] { 3f, 1f }); - AssertHits(new FunctionQuery(new TermFreqValueSource("bogus", "bogus", "string", new BytesRef("bar"))), new[] { 0f, 1f }); + AssertHits(new FunctionQuery( + new TermFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), + new[] { 3f, 1f }); + AssertHits(new FunctionQuery( + new TermFreqValueSource("bogus", "bogus", "string", new BytesRef("bar"))), + new[] { 0f, 1f }); } [Test] @@ -320,8 +374,12 @@ public void TestTF() { // no norm field (so agnostic to indexed similarity) searcher.Similarity = new DefaultSimilarity(); - AssertHits(new FunctionQuery(new TFValueSource("bogus", "bogus", "text", new BytesRef("test"))), new[] { (float)Math.Sqrt(3d), (float)Math.Sqrt(1d) }); - AssertHits(new FunctionQuery(new TFValueSource("bogus", "bogus", "string", new BytesRef("bar"))), new[] { 0f, 1f }); + AssertHits(new FunctionQuery( + new TFValueSource("bogus", "bogus", "text", new BytesRef("test"))), + new[] { (float)Math.Sqrt(3d), (float)Math.Sqrt(1d) }); + AssertHits(new FunctionQuery( + new TFValueSource("bogus", "bogus", "string", new BytesRef("bar"))), + new[] { 0f, 1f }); } finally { @@ -334,11 +392,15 @@ public void TestTotalTermFreq() { if (Codec.Default.Name.Equals("Lucene3x", StringComparison.Ordinal)) { - AssertHits(new FunctionQuery(new TotalTermFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), new[] { -1f, -1f }); + AssertHits(new FunctionQuery( + new TotalTermFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), + new[] { -1f, -1f }); } else { - AssertHits(new FunctionQuery(new TotalTermFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), new[] { 4f, 4f }); + AssertHits(new FunctionQuery( + new TotalTermFreqValueSource("bogus", "bogus", "text", new BytesRef("test"))), + new[] { 4f, 4f }); } } @@ -351,7 +413,8 @@ private void AssertHits(Query q, float[] scores) expectedDocs[i] = i; expected[i] = new ScoreDoc(i, scores[i]); } - TopDocs docs = searcher.Search(q, null, documents.Count, new Sort(new SortField("id", SortFieldType.STRING)), true, false); + TopDocs docs = searcher.Search(q, null, documents.Count, + new Sort(new SortField("id", SortFieldType.STRING)), true, false); CheckHits.DoCheckHits( #if FEATURE_INSTANCE_TESTDATA_INITIALIZATION this, diff --git a/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs b/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs index 2f492e61e1..0a5fc6245d 100644 --- a/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs +++ b/src/Lucene.Net.Tests.Queries/Mlt/TestMoreLikeThis.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +// Lucene version compatibility level 4.8.1 +using System.Collections.Generic; using System.IO; using Lucene.Net.Analysis; using Lucene.Net.Documents; @@ -99,7 +100,8 @@ public void TestBoostFactor() assertNotNull("Expected term " + tq.Term.Text(), termBoost); float totalBoost = (float) (termBoost * boostFactor); - assertEquals("Expected boost of " + totalBoost + " for term '" + tq.Term.Text() + "' got " + tq.Boost, totalBoost, tq.Boost, 0.0001); + assertEquals("Expected boost of " + totalBoost + " for term '" + + tq.Term.Text() + "' got " + tq.Boost, totalBoost, tq.Boost, 0.0001); } } diff --git a/src/Lucene.Net.Tests.Queries/TermFilterTest.cs b/src/Lucene.Net.Tests.Queries/TermFilterTest.cs index c4a403c3db..d8cd554976 100644 --- a/src/Lucene.Net.Tests.Queries/TermFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/TermFilterTest.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using System.Collections.Generic; using Lucene.Net.Documents; using Lucene.Net.Index; @@ -58,15 +59,19 @@ public void TestMissingTermAndField() assertTrue(reader.Context is AtomicReaderContext); var context = (AtomicReaderContext)reader.Context; w.Dispose(); + DocIdSet idSet = TermFilter(fieldName, @"value1").GetDocIdSet(context, context.AtomicReader.LiveDocs); assertNotNull(@"must not be null", idSet); DocIdSetIterator iter = idSet.GetIterator(); assertEquals(iter.NextDoc(), 0); assertEquals(iter.NextDoc(), DocIdSetIterator.NO_MORE_DOCS); + idSet = TermFilter(fieldName, @"value2").GetDocIdSet(context, context.AtomicReader.LiveDocs); assertNull(@"must be null", idSet); + idSet = TermFilter(@"field2", @"value1").GetDocIdSet(context, context.AtomicReader.LiveDocs); assertNull(@"must be null", idSet); + reader.Dispose(); rd.Dispose(); } @@ -94,12 +99,15 @@ public void TestRandom() IndexReader reader = w.GetReader(); w.Dispose(); + IndexSearcher searcher = NewSearcher(reader); + int numQueries = AtLeast(10); for (int i = 0; i < numQueries; i++) { Term term = terms[Random.nextInt(num)]; TopDocs queryResult = searcher.Search(new TermQuery(term), reader.MaxDoc); + MatchAllDocsQuery matchAll = new MatchAllDocsQuery(); TermFilter filter = TermFilter(term); TopDocs filterResult = searcher.Search(matchAll, filter, reader.MaxDoc); @@ -124,16 +132,13 @@ public void TestHashCodeAndEquals() string field1 = @"field" + i; string field2 = @"field" + i + num; string value1 = TestUtil.RandomRealisticUnicodeString(Random); - string value2 = value1 + @"x"; + string value2 = value1 + @"x"; // this must be not equal to value1 + TermFilter filter1 = TermFilter(field1, value1); TermFilter filter2 = TermFilter(field1, value2); TermFilter filter3 = TermFilter(field2, value1); TermFilter filter4 = TermFilter(field2, value2); - var filters = new TermFilter[] - { - filter1, filter2, filter3, filter4 - }; - + var filters = new TermFilter[] { filter1, filter2, filter3, filter4 }; for (int j = 0; j < filters.Length; j++) { TermFilter termFilter = filters[j]; diff --git a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs index 7627f18865..660b4b7cd3 100644 --- a/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs +++ b/src/Lucene.Net.Tests.Queries/TermsFilterTest.cs @@ -1,5 +1,7 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using J2N.Collections.Generic.Extensions; using Lucene.Net.Documents; @@ -88,7 +90,7 @@ public void TestMissingTerms() reader.Dispose(); rd.Dispose(); } - + [Test] public void TestMissingField() { @@ -171,7 +173,7 @@ public void TestFieldNotPresent() - AtomicReaderContext context = reader.Leaves.First(); + AtomicReaderContext context = reader.Leaves[0]; TermsFilter tf = new TermsFilter(terms); FixedBitSet bits = (FixedBitSet)tf.GetDocIdSet(context, context.AtomicReader.LiveDocs); @@ -217,7 +219,7 @@ public void TestSkipField() IndexReader reader = w.GetReader(); w.Dispose(); assertEquals(1, reader.Leaves.size()); - AtomicReaderContext context = reader.Leaves.First(); + AtomicReaderContext context = reader.Leaves[0]; TermsFilter tf = new TermsFilter(terms.ToList()); FixedBitSet bits = (FixedBitSet)tf.GetDocIdSet(context, context.AtomicReader.LiveDocs); @@ -240,7 +242,7 @@ public void TestRandom() IList terms = new List(); for (int i = 0; i < num; i++) { - string field = "field" + (singleField ? "1" : Random.Next(100).ToString()); + string field = "field" + (singleField ? "1" : Random.Next(100).ToString(CultureInfo.InvariantCulture)); string @string = TestUtil.RandomRealisticUnicodeString(Random); terms.Add(new Term(field, @string)); Document doc = new Document(); @@ -398,7 +400,10 @@ public void TestNoTerms() [Test] public void TestToString() { - TermsFilter termsFilter = new TermsFilter(new Term("field1", "a"), new Term("field1", "b"), new Term("field1", "c")); + TermsFilter termsFilter = new TermsFilter( + new Term("field1", "a"), + new Term("field1", "b"), + new Term("field1", "c")); assertEquals("field1:a field1:b field1:c", termsFilter.ToString()); } } diff --git a/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs b/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs index 47d3052808..7c60bc0b1c 100644 --- a/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs +++ b/src/Lucene.Net.Tests.Queries/TestCustomScoreQuery.cs @@ -1,4 +1,5 @@ -using System; +// Lucene version compatibility level 4.8.1 +using System; using System.Collections.Generic; using Lucene.Net.Index; using Lucene.Net.Queries; @@ -89,7 +90,8 @@ public virtual void TestCustomScoreFloat() private class CustomAddQuery : CustomScoreQuery { // constructor - internal CustomAddQuery(Query q, FunctionQuery qValSrc) : base(q, qValSrc) + internal CustomAddQuery(Query q, FunctionQuery qValSrc) + : base(q, qValSrc) { } @@ -129,7 +131,8 @@ public override Explanation CustomExplain(int doc, Explanation subQueryExpl, Exp private class CustomMulAddQuery : CustomScoreQuery { // constructor - internal CustomMulAddQuery(Query q, FunctionQuery qValSrc1, FunctionQuery qValSrc2) : base(q, qValSrc1, qValSrc2) + internal CustomMulAddQuery(Query q, FunctionQuery qValSrc1, FunctionQuery qValSrc2) + : base(q, qValSrc1, qValSrc2) { } @@ -259,7 +262,8 @@ public virtual void TestRewrite() r.Dispose(); } - + + // Test that FieldScoreQuery returns docs with expected score. private void DoTestCustomScore(ValueSource valueSource, double dboost) { float boost = (float)dboost; @@ -310,18 +314,22 @@ private void DoTestCustomScore(ValueSource valueSource, double dboost) TopDocs td5CustomMulAdd = s.Search(q5CustomMulAdd, null, 1000); // put results in map so we can verify the scores although they have changed - IDictionary h1 = TopDocsToMap(td1); - IDictionary h2CustomNeutral = TopDocsToMap(td2CustomNeutral); - IDictionary h3CustomMul = TopDocsToMap(td3CustomMul); - IDictionary h4CustomAdd = TopDocsToMap(td4CustomAdd); - IDictionary h5CustomMulAdd = TopDocsToMap(td5CustomMulAdd); - - VerifyResults(boost, s, h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd, q1, q2CustomNeutral, q3CustomMul, q4CustomAdd, q5CustomMulAdd); + IDictionary h1 = TopDocsToMap(td1); + IDictionary h2CustomNeutral = TopDocsToMap(td2CustomNeutral); + IDictionary h3CustomMul = TopDocsToMap(td3CustomMul); + IDictionary h4CustomAdd = TopDocsToMap(td4CustomAdd); + IDictionary h5CustomMulAdd = TopDocsToMap(td5CustomMulAdd); + + VerifyResults(boost, s, + h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd, + q1, q2CustomNeutral, q3CustomMul, q4CustomAdd, q5CustomMulAdd); r.Dispose(); } // verify results are as expected. - private void VerifyResults(float boost, IndexSearcher s, IDictionary h1, IDictionary h2customNeutral, IDictionary h3CustomMul, IDictionary h4CustomAdd, IDictionary h5CustomMulAdd, Query q1, Query q2, Query q3, Query q4, Query q5) + private void VerifyResults(float boost, IndexSearcher s, + IDictionary h1, IDictionary h2customNeutral, IDictionary h3CustomMul, IDictionary h4CustomAdd, IDictionary h5CustomMulAdd, + Query q1, Query q2, Query q3, Query q4, Query q5) { // verify numbers of matches