-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear only when starting search, added lastDoc for pagination (#3967)
Co-authored-by: Ramin Haeri Azad <[email protected]>
- Loading branch information
Showing
9 changed files
with
112 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
opal-search/src/main/java/org/obiba/opal/search/service/support/ScoreDocSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.obiba.opal.search.service.support; | ||
|
||
import org.apache.lucene.search.ScoreDoc; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
|
||
public class ScoreDocSerializer { | ||
public static String serialize(ScoreDoc scoreDoc) { | ||
String doc = scoreDoc.doc + ":" + scoreDoc.score + ":" + scoreDoc.shardIndex; | ||
return Base64.getEncoder().encodeToString(doc.getBytes(StandardCharsets.UTF_8)); | ||
} | ||
|
||
public static ScoreDoc deserialize(String serialized) { | ||
byte[] decoded = Base64.getDecoder().decode(serialized); | ||
String[] parts = new String(decoded, StandardCharsets.UTF_8).split(":"); | ||
return new ScoreDoc(Integer.parseInt(parts[0]), Float.parseFloat(parts[1]), Integer.parseInt(parts[2])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters