Skip to content

Commit

Permalink
fixes #192: Return results for keyword and participant(s) combination…
Browse files Browse the repository at this point in the history
… query

Using a term-based query for the JIDs of participants when searching through the Lucene index.
  • Loading branch information
guusdk committed Aug 9, 2021
1 parent 398f722 commit 421b6e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h1>
<ul>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/125'>Issue #125</a>] - Combining keyword and date range makes search fail</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/190'>Issue #190</a>] - Allow code-update to force a reindexation</li>
<li>[<a href='https://github.com/igniterealtime/openfire-monitoring-plugin/issues/192'>Issue #192</a>] - Combining keyword and participant(s) makes search fail</li>
</ul>

<p><b>2.2.1</b> -- February 12, 2021</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private void indexDocument(IndexWriter writer, long conversationID, boolean exte
document.add(new StringField("external", String.valueOf(external), Field.Store.NO));
document.add(new NumericDocValuesField("date", date.toEpochMilli()));
for (JID jid : jids) {
document.add(new StringField("jid", jid.toString(), Field.Store.NO));
document.add(new StringField("jid", jid.toBareJID(), Field.Store.NO));
}
document.add(new TextField("text", text, Field.Store.NO));
writer.addDocument(document);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private Collection<Conversation> luceneSearch(ArchiveSearch search) {
if (!participants.isEmpty()) {
if (participants.size() == 1) {
JID jid = participants.iterator().next().asBareJID();
Query participantQuery = new QueryParser("jid", analyzer).parse(jid.toString());
TermQuery participantQuery = new TermQuery(new Term("jid", jid.toBareJID()));
Log.debug( "... restricting to participant: {}", jid );

// Add this query to the existing query.
Expand All @@ -177,8 +177,8 @@ private Collection<Conversation> luceneSearch(ArchiveSearch search) {

Log.debug( "... restricting to participants: {} and {}", participant1, participant2 );
final BooleanQuery participantQuery = new BooleanQuery.Builder()
.add(new QueryParser("jid", analyzer).parse(participant1), BooleanClause.Occur.MUST)
.add(new QueryParser("jid", analyzer).parse(participant2), BooleanClause.Occur.MUST)
.add(new TermQuery(new Term("jid", participant1)), BooleanClause.Occur.MUST)
.add(new TermQuery(new Term("jid", participant2)), BooleanClause.Occur.MUST)
.build();

// Add this query to the existing query.
Expand Down

0 comments on commit 421b6e3

Please sign in to comment.