mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-11 18:20:33 +09:00
Merge pull request #1992 from anyproto/go-4804-notes-dont-appear-in-searches
GO-4804 fulltext: index snippet for notes
This commit is contained in:
commit
bf4c929d8a
2 changed files with 19 additions and 3 deletions
|
@ -161,13 +161,23 @@ func (i *indexer) prepareSearchDocument(ctx context.Context, id string) (docs []
|
|||
if rel.Format != model.RelationFormat_shorttext && rel.Format != model.RelationFormat_longtext {
|
||||
continue
|
||||
}
|
||||
val := sb.Details().GetString(domain.RelationKey(rel.Key))
|
||||
val := sb.CombinedDetails().GetString(domain.RelationKey(rel.Key))
|
||||
if val == "" {
|
||||
continue
|
||||
}
|
||||
// skip readonly and hidden system relations
|
||||
if bundledRel, err := bundle.PickRelation(domain.RelationKey(rel.Key)); err == nil {
|
||||
if bundledRel.ReadOnly || bundledRel.Hidden && rel.Key != bundle.RelationKeyName.String() {
|
||||
layout, _ := sb.Layout()
|
||||
skip := bundledRel.ReadOnly || bundledRel.Hidden
|
||||
if rel.Key == bundle.RelationKeyName.String() {
|
||||
skip = false
|
||||
}
|
||||
if layout == model.ObjectType_note && rel.Key == bundle.RelationKeySnippet.String() {
|
||||
// index snippet only for notes, so we will be able to do fast prefix queries
|
||||
skip = false
|
||||
}
|
||||
|
||||
if skip {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -419,7 +419,13 @@ func (f *ftSearchTantivy) performSearch(spaceId, query string, buildQueryFunc fu
|
|||
}
|
||||
|
||||
func (f *ftSearchTantivy) buildObjectQuery(qb *tantivy.QueryBuilder, query string) {
|
||||
qb.Query(tantivy.Must, fieldId, bundle.RelationKeyName.String(), tantivy.TermQuery, 1.0)
|
||||
qb.BooleanQuery(tantivy.Must, qb.NestedBuilder().
|
||||
Query(tantivy.Should, fieldId, bundle.RelationKeyName.String(), tantivy.TermQuery, 1.0).
|
||||
// snippets are indexed only for notes which don't have a name, we should do a prefix search there as well
|
||||
Query(tantivy.Should, fieldId, bundle.RelationKeySnippet.String(), tantivy.TermQuery, 1.0),
|
||||
1.0,
|
||||
)
|
||||
|
||||
if containsChineseCharacters(query) {
|
||||
qb.BooleanQuery(tantivy.Must, qb.NestedBuilder().
|
||||
Query(tantivy.Should, fieldTitleZh, query, tantivy.PhrasePrefixQuery, 1.0).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue