Percolator: Failures when using docs where fields repeat, such as arrays, closes #763.
This commit is contained in:
parent
c7b36f113d
commit
f694b9dfd8
File diff suppressed because it is too large
Load Diff
|
@ -22,7 +22,7 @@ package org.elasticsearch.index.percolator;
|
|||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.memory.MemoryIndex;
|
||||
import org.apache.lucene.index.memory.CustomMemoryIndex;
|
||||
import org.apache.lucene.search.Collector;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
|
@ -302,7 +302,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
|
|||
|
||||
public Response percolate(DocAndQueryRequest request) throws ElasticSearchException {
|
||||
// first, parse the source doc into a MemoryIndex
|
||||
final MemoryIndex memoryIndex = new MemoryIndex();
|
||||
final CustomMemoryIndex memoryIndex = new CustomMemoryIndex();
|
||||
|
||||
for (Fieldable field : request.doc().doc().getFields()) {
|
||||
if (!field.isIndexed()) {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search 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.
|
||||
*/
|
||||
|
||||
package org.apache.lucene.index.memory;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class CustomMemoryIndexTests {
|
||||
|
||||
@Test public void testSameFieldSeveralTimes() throws Exception {
|
||||
CustomMemoryIndex memoryIndex = new CustomMemoryIndex();
|
||||
memoryIndex.addField("field1", "value1", Lucene.KEYWORD_ANALYZER);
|
||||
memoryIndex.addField("field1", "value2", Lucene.KEYWORD_ANALYZER);
|
||||
|
||||
IndexSearcher searcher = memoryIndex.createSearcher();
|
||||
assertThat(searcher.search(new TermQuery(new Term("field1", "value1")), 10).totalHits, equalTo(1));
|
||||
assertThat(searcher.search(new TermQuery(new Term("field1", "value2")), 10).totalHits, equalTo(1));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue