Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/small-adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaddalena authored Dec 10, 2024
2 parents 3f42155 + ecfbe1c commit ce0988e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ghostwriter/oplog/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Django Imports
from django.db.models import TextField, Func, Subquery, OuterRef, Value, F
from django.db.models.functions import Cast
from django.db.models.functions import Cast, Left
from django.db.models.expressions import CombinedExpression
from django.utils.timezone import make_aware
from django.contrib.postgres.search import SearchVector, SearchQuery, SearchRank, SearchVectorField
Expand Down Expand Up @@ -164,20 +164,20 @@ def get_log_entries(self, oplog_id: int, offset: int, user: User, filter: str |
if spec.type == "json":
continue

field = Cast(CombinedExpression(
field = CombinedExpression(
F("extra_fields"),
"->>",
Value(spec.internal_name),
), TextField())
)
simple_vector_args.append(field)
if spec.type == "rich_text":
english_vector_args.append(field)

# Combine search vector
vector = TsVectorConcat(
SearchVector(*english_vector_args, config="english"),
SearchVector(*simple_vector_args, config="simple"),
)
# Create and combine search vectors.
# Limit inputs since PostgreSQL will abort the query if attempting to make a tsvector out of a huge string
vectors = [SearchVector(Left(Cast(va, TextField()), 100000), config="english") for va in english_vector_args] + \
[SearchVector(Left(Cast(va, TextField()), 100000), config="simple") for va in simple_vector_args]
vector = TsVectorConcat(*vectors)

# Build filter.
# Search using both english and simple configs, to help match both types of vectors. Also use prefix
Expand Down

0 comments on commit ce0988e

Please sign in to comment.