mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-02 09:05:08 +00:00
Allow some solr query options in the config file
This commit is contained in:
parent
793f33b640
commit
14213c4c27
@ -33,7 +33,12 @@ object QueryData {
|
||||
implicit val jsonEncoder: Encoder[QueryData] =
|
||||
deriveEncoder[QueryData]
|
||||
|
||||
def apply(search: List[Field], fields: List[Field], fq: FtsQuery): QueryData = {
|
||||
def apply(
|
||||
cfg: SolrConfig,
|
||||
search: List[Field],
|
||||
fields: List[Field],
|
||||
fq: FtsQuery
|
||||
): QueryData = {
|
||||
val q = sanitize(fq.q)
|
||||
val extQ = search.map(f => s"${f.name}:($q)").mkString(" OR ")
|
||||
val items = fq.items.map(_.id).mkString(" ")
|
||||
@ -44,7 +49,14 @@ object QueryData {
|
||||
case _ =>
|
||||
(collQ :: List(s"""${Field.itemId.name}:($items)""")).mkString(" AND ")
|
||||
}
|
||||
QueryData(extQ, filterQ, fq.limit, fq.offset, fields, Map.empty).withHighLight(
|
||||
QueryData(
|
||||
extQ,
|
||||
filterQ,
|
||||
fq.limit,
|
||||
fq.offset,
|
||||
fields,
|
||||
Map("defType" -> cfg.defType, "q.op" -> cfg.qOp)
|
||||
).withHighLight(
|
||||
search,
|
||||
fq.highlight.pre,
|
||||
fq.highlight.post
|
||||
|
@ -2,6 +2,12 @@ package docspell.ftssolr
|
||||
|
||||
import docspell.common._
|
||||
|
||||
final case class SolrConfig(url: LenientUri, commitWithin: Int, logVerbose: Boolean)
|
||||
final case class SolrConfig(
|
||||
url: LenientUri,
|
||||
commitWithin: Int,
|
||||
logVerbose: Boolean,
|
||||
defType: String,
|
||||
qOp: String
|
||||
)
|
||||
|
||||
object SolrConfig {}
|
||||
|
@ -15,29 +15,7 @@ trait SolrQuery[F[_]] {
|
||||
|
||||
def query(q: QueryData): F[FtsResult]
|
||||
|
||||
def query(q: FtsQuery): F[FtsResult] = {
|
||||
val fq = QueryData(
|
||||
List(
|
||||
Field.content,
|
||||
Field.content_de,
|
||||
Field.content_en,
|
||||
Field.itemName,
|
||||
Field.itemNotes,
|
||||
Field.attachmentName
|
||||
),
|
||||
List(
|
||||
Field.id,
|
||||
Field.itemId,
|
||||
Field.collectiveId,
|
||||
Field("score"),
|
||||
Field.attachmentId,
|
||||
Field.attachmentName,
|
||||
Field.discriminator
|
||||
),
|
||||
q
|
||||
)
|
||||
query(fq)
|
||||
}
|
||||
def query(q: FtsQuery): F[FtsResult]
|
||||
}
|
||||
|
||||
object SolrQuery {
|
||||
@ -53,6 +31,30 @@ object SolrQuery {
|
||||
client.expect[FtsResult](req)
|
||||
}
|
||||
|
||||
def query(q: FtsQuery): F[FtsResult] = {
|
||||
val fq = QueryData(
|
||||
cfg,
|
||||
List(
|
||||
Field.content,
|
||||
Field.content_de,
|
||||
Field.content_en,
|
||||
Field.itemName,
|
||||
Field.itemNotes,
|
||||
Field.attachmentName
|
||||
),
|
||||
List(
|
||||
Field.id,
|
||||
Field.itemId,
|
||||
Field.collectiveId,
|
||||
Field("score"),
|
||||
Field.attachmentId,
|
||||
Field.attachmentName,
|
||||
Field.discriminator
|
||||
),
|
||||
q
|
||||
)
|
||||
query(fq)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,6 +382,12 @@ docspell.joex {
|
||||
commit-within = 1000
|
||||
# If true, logs request and response bodies
|
||||
log-verbose = false
|
||||
# The defType parameter to lucene that defines the parser to
|
||||
# use. You might want to try "edismax" or look here:
|
||||
# https://lucene.apache.org/solr/guide/8_4/query-syntax-and-parsing.html#query-syntax-and-parsing
|
||||
def-type = "lucene"
|
||||
# The default combiner for tokens. One of {AND, OR}.
|
||||
q-op = "OR"
|
||||
}
|
||||
|
||||
# Settings for running the index migration tasks
|
||||
|
@ -109,8 +109,13 @@ docspell.server {
|
||||
commit-within = 1000
|
||||
# If true, logs request and response bodies
|
||||
log-verbose = false
|
||||
# The defType parameter to lucene that defines the parser to
|
||||
# use. You might want to try "edismax" or look here:
|
||||
# https://lucene.apache.org/solr/guide/8_4/query-syntax-and-parsing.html#query-syntax-and-parsing
|
||||
def-type = "lucene"
|
||||
# The default combiner for tokens. One of {AND, OR}.
|
||||
q-op = "OR"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Configuration for the backend.
|
||||
|
Loading…
x
Reference in New Issue
Block a user