Skip to content

Commit

Permalink
Improve compatibility w/ Solr 7
Browse files Browse the repository at this point in the history
Added `op` and `df` to default query params
  • Loading branch information
mikesname committed Aug 30, 2023
1 parent 8b1de70 commit b815e77
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

# 2 space indentation
[*.{scala,js}]
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tmp
dist
*.sublime-workspace
OLD
JUNK
DB
*.pyc
*.jar
Expand All @@ -38,3 +39,4 @@ conf/external_pages.conf
conf/dos.conf*
conf/minio.conf*
conf/api-keys.conf*
solr*
9 changes: 8 additions & 1 deletion conf/search.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ search {
# default to OR for q param
andMode: false

defaultField: text

fields = [
itemId
identifier
Expand Down Expand Up @@ -43,7 +45,12 @@ search {

# Array of additional fields to include in the default search,
# without boost.
extraFields = []
extraFields = [
txt_fr
txt_el
txt_de
txt_pl
]

# Spellcheck config
spellcheck {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ private[solr] object SolrQueryBuilder {
} else Seq.empty
}

def basicParams(queryString: String, paging: PageParams, debug: Boolean): Seq[(String, String)] = Seq(
def basicParams(queryString: String, paging: PageParams, debug: Boolean, df: String): Seq[(String, String)] = Seq(
"q" -> queryString,
"q.op" -> "or",
"wt" -> "json",
"df" -> df,
"start" -> paging.offset.toString,
"rows" -> paging.limit.toString,
"debugQuery" -> debug.toString,
Expand Down Expand Up @@ -258,7 +260,7 @@ case class SolrQueryBuilder @Inject()(config: Configuration) extends QueryBuilde

private val jsonFacets = config.getOptional[Boolean]("search.jsonFacets").getOrElse(false)
private val enableDebug = config.getOptional[Boolean]("search.debugTiming").getOrElse(false)

private val defaultField = config.get[String]("search.defaultField")
private lazy val queryFields: Seq[String] = config.get[Seq[String]]("search.fields")

/**
Expand All @@ -284,7 +286,7 @@ case class SolrQueryBuilder @Inject()(config: Configuration) extends QueryBuilde
val queryString = localParam + query.params.query.getOrElse("*").trim

Seq(
basicParams(queryString, query.paging, enableDebug),
basicParams(queryString, query.paging, enableDebug, defaultField),
entityFilterParams(query.params.entities),
bboxParams(query.params.bbox),
latLngParams(query.params.latLng),
Expand Down Expand Up @@ -318,7 +320,7 @@ case class SolrQueryBuilder @Inject()(config: Configuration) extends QueryBuilde
val queryString = localParam + query.params.query.getOrElse(defaultQuery).trim

Seq(
basicParams(queryString, query.paging, enableDebug),
basicParams(queryString, query.paging, enableDebug, defaultField),
groupParams(query.lang),
fieldParams(query.params.fields, queryFieldsWithBoost, config),
sortParams(query.params.sort),
Expand Down

0 comments on commit b815e77

Please sign in to comment.