Skip to content

Commit

Permalink
Remove min length constraint on term search (Issue #226) 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Oct 10, 2022
1 parent 13720b4 commit b09058d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/Client/Pages/TermSearch/TermSearchView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ let update (termSearchMsg: TermSearch.Msg) (currentState:TermSearch.Model) : Ter

| SearchTermTextChange newTerm ->

let triggerNewSearch =
newTerm.Length > 2
let triggerNewSearch = newTerm.Trim() <> ""

let (delay, bounceId, msgToBounce) =
(System.TimeSpan.FromSeconds 0.5),
(System.TimeSpan.FromSeconds 1.),
"GetNewTermSuggestions",
(
if triggerNewSearch then
Expand Down
18 changes: 6 additions & 12 deletions src/Server/Database/Term.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,14 @@ type Term(?credentials:Neo4JCredentials, ?session:IAsyncSession) =
if searchType.IsSome then
searchType.Value.ofQueryString termName
else
FullTextSearch.Complete.ofQueryString termName
FullTextSearch.PerformanceComplete.ofQueryString termName
let query =
let sourceOntologyText = """ WHERE EXISTS((:Term {accession: node.accession})-[:CONTAINED_IN]->(:Ontology {name: $OntologyName})) """
if searchType.IsSome && searchType.Value = FullTextSearch.Exact then
sprintf
"""MATCH (node:Term {name: $Name})%s
RETURN node.accession, node.name, node.definition, node.is_obsolete"""
(if sourceOntologyName.IsSome then sourceOntologyText else "")
else
sprintf
"""CALL db.index.fulltext.queryNodes("TermName",$Name)
YIELD node%s
RETURN node.accession, node.name, node.definition, node.is_obsolete"""
(if sourceOntologyName.IsSome then sourceOntologyText else "")
sprintf
"""CALL db.index.fulltext.queryNodes("TermName",$Name)
YIELD node%s
RETURN node.accession, node.name, node.definition, node.is_obsolete"""
(if sourceOntologyName.IsSome then sourceOntologyText else "")
let param =
Map [
"Name",fulltextSearchStr
Expand Down
4 changes: 3 additions & 1 deletion src/Server/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ let ontologyApi (credentials : Helper.Neo4JCredentials) : IOntologyAPIv1 =
Term.Term(credentials).getByAccession foundAccession.Value
// This suggests we search for a term name
| notAnAccession ->
Term.Term(credentials).getByName notAnAccession
let searchTextLength = typedSoFar.Length
let searchmode = if searchTextLength < 3 then Database.Helper.FullTextSearch.Exact else Database.Helper.FullTextSearch.PerformanceComplete
Term.Term(credentials).getByName(notAnAccession, searchmode)
|> Array.ofSeq
|> sorensenDiceSortTerms typedSoFar
let arr = if dbSearchRes.Length <= max then dbSearchRes else Array.take max dbSearchRes
Expand Down

0 comments on commit b09058d

Please sign in to comment.