Skip to content

Commit 0187de7

Browse files
committed
XWIKI-23824: Double search result after upgrade to 17.10.0
1 parent 12591b3 commit 0187de7

2 files changed

Lines changed: 37 additions & 15 deletions

File tree

  • xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-api/src/main/java/org/xwiki/search/solr/internal/job
  • xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test/xwiki-platform-distribution-flavor-test-upgrade/xwiki-platform-distribution-flavor-test-upgrade-1610/src/test/it/org/xwiki/test/ui

xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-api/src/main/java/org/xwiki/search/solr/internal/job/IndexerJob.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public class IndexerJob extends AbstractJob<IndexerRequest, DefaultJobStatus<Ind
6767
*/
6868
private static final JobGroupPath GROUP = new JobGroupPath(Arrays.asList("solr", "indexer"));
6969

70+
private static final String AND = " AND ";
71+
7072
/**
7173
* Used to send documents to index or delete to/from Solr index.
7274
*/
@@ -205,37 +207,33 @@ private void cleanInvalid() throws SolrServerException, IOException, SolrIndexer
205207
{
206208
StringBuilder builder = new StringBuilder();
207209

210+
// Filter documents based on the indicated root reference
211+
builder.append('(');
212+
builder.append(this.solrReferenceResolver.getQuery(getRequest().getRootReference()));
213+
builder.append(')');
214+
215+
builder.append(AND);
216+
217+
builder.append('-');
208218
builder.append('(');
209219

210220
// All entries which don't have a docId set
211-
builder.append(notSet(FieldUtils.DOC_ID));
221+
builder.append(FieldUtils.DOC_ID);
212222

213-
builder.append(" OR ");
223+
builder.append(AND);
214224

215225
// All entries which don't have a fullName set
216-
builder.append(notSet(FieldUtils.FULLNAME));
226+
builder.append(FieldUtils.FULLNAME);
217227

218228
// TODO: Remove from the core all entries for which no corresponding DOCUMENT type entry exist (see
219229
// https://jira.xwiki.org/browse/XWIKI-22949)
220230

221231
builder.append(')');
222232

223-
builder.append(" AND ");
224-
225-
// Filter documents based on the indicated root reference
226-
builder.append('(');
227-
builder.append(this.solrReferenceResolver.getQuery(getRequest().getRootReference()));
228-
builder.append(')');
229-
230233
// Execute the delete
231234
this.solrInstance.deleteByQuery(builder.toString());
232235

233236
// Commit
234237
this.solrInstance.commit();
235238
}
236-
237-
private String notSet(String field)
238-
{
239-
return "-" + field + ":*";
240-
}
241239
}

xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test/xwiki-platform-distribution-flavor-test-upgrade/xwiki-platform-distribution-flavor-test-upgrade-1610/src/test/it/org/xwiki/test/ui/Upgrade1610Test.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,35 @@
1919
*/
2020
package org.xwiki.test.ui;
2121

22+
import org.xwiki.rendering.syntax.Syntax;
23+
24+
import static org.junit.jupiter.api.Assertions.assertEquals;
25+
2226
/**
2327
* Execute upgrade tests.
2428
*
2529
* @version $Id$
2630
*/
2731
public class Upgrade1610Test extends UpgradeTest
2832
{
33+
@Override
34+
protected void postUpdateValidate() throws Exception
35+
{
36+
// Make sure the Solr migration went as planned
37+
assertSolrMigration();
38+
}
39+
40+
private void assertSolrMigration() throws Exception
41+
{
42+
// We expect the default Sandbox home page which id was generated based on the default locale to be removed
43+
String result = getUtil().executeWikiPlain("""
44+
{{velocity}}
45+
#if ($services.component.getInstance('org.xwiki.search.solr.internal.api.SolrInstance').get('xwiki:Sandbox.WebHome_en'))true#{else}false#end
46+
47+
#if ($services.component.getInstance('org.xwiki.search.solr.internal.api.SolrInstance').get('xwiki:Sandbox.WebHome_'))true#{else}false#end
48+
{{/velocity}}
49+
""", Syntax.XWIKI_2_1);
50+
51+
assertEquals("false\ntrue", result.trim());
52+
}
2953
}

0 commit comments

Comments
 (0)