Fix the problem of null type of search result (#6241)

#### What type of PR is this?

/kind bug
/area core
/milestone 2.17.0

#### What this PR does / why we need it:

This PR adds missed type to HaloDocument while converting.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/6235

#### Does this PR introduce a user-facing change?

```release-note
None
```
pull/6191/head^2
John Niang 2024-07-01 17:25:17 +08:00 committed by GitHub
parent 4ea4bdf8b5
commit bbc6f23b2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -348,6 +348,7 @@ public class LuceneSearchEngine implements SearchEngine, InitializingBean, Dispo
public HaloDocument convert(Document doc) {
var haloDoc = new HaloDocument();
haloDoc.setId(doc.get("id"));
haloDoc.setType(doc.get("type"));
haloDoc.setMetadataName(doc.get("name"));
haloDoc.setTitle(doc.get("title"));
haloDoc.setDescription(doc.get("description"));

View File

@ -102,6 +102,7 @@ public class LuceneSearchEngineIntegrationTest {
assertEquals(1, hits.size());
var doc = hits.get(0);
assertEquals("post.content.halo.run-first-post", doc.getId());
assertEquals("post.content.halo.run", doc.getType());
assertEquals("first <my-tag>halo</my-tag> post", doc.getTitle());
assertNull(doc.getDescription());
assertEquals("<my-tag>halo</my-tag>", doc.getContent());