Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing of Quarkiverse guide content #57

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/io/quarkus/search/app/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public SearchResult<GuideSearchHit> search(@RestQuery @DefaultValue(QuarkusVersi
.field("fullContent_autocomplete").boost(0.1f)
.matching(q)
.defaultOperator(BooleanOperator.AND))
.should(f.match().field("origin").matching("quarkus").boost(50.0f))
.should(f.not(f.match().field("topics").matching("compatibility"))
.boost(50.0f)));
}
Expand Down
34 changes: 0 additions & 34 deletions src/main/java/io/quarkus/search/app/asciidoc/Asciidoc.java

This file was deleted.

18 changes: 18 additions & 0 deletions src/main/java/io/quarkus/search/app/entity/Guide.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.persistence.Id;

import java.net.URI;
import java.util.Objects;
import java.util.Set;

import org.hibernate.Length;
Expand Down Expand Up @@ -75,6 +76,23 @@ public class Guide {
@KeywordField(name = "extensions_faceting", searchable = Searchable.YES, projectable = Projectable.YES, aggregable = Aggregable.YES)
public Set<String> extensions = Set.of();

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Guide guide = (Guide) o;
return Objects.equals(url, guide.url);
}

@Override
public int hashCode() {
return Objects.hash(url);
}

@Override
public String toString() {
return "Guide{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ public String toIndexedValue(InputProvider provider, ValueBridgeToIndexedValueCo
// Means we've found a guide content column. hence let's use that to have only real content:
return content.text();
} else {
Log.warn("Was unable to find the content section of a guide. Using whole document as text. " + provider);
return body.text();
// we might be looking at a quarkiverse guide; in such case:
content = body.selectFirst("article.doc");
if (content != null) {
// Means we've found a guide content column. hence let's use that to have only real content:
return content.text();
} else {
Log.warnf("Was unable to find the content section of a guide. Using whole document as text. %s", provider);
return body.text();
}
}
} catch (RuntimeException | IOException e) {
throw new IllegalStateException("Failed to read '" + provider + "' for indexing: " + e.getMessage(), e);
Expand Down
Loading
Loading