Lucene Multi Term Query field search working example in Scala

val searchInput = Map(“First Name” -> “John”, “Last Name” -> “Do”)

val parser = new MultiFieldQueryParser(searchInput.keySet.toArray, new CaseInsensitiveWhitespaceAnalyzer())

parser.setDefaultOperator(QueryParserBase.AND_OPERATOR)

val queryString = searchInput.map(i => “(“ + i._1.replaceAll(“ “, “\\\\ “) + “:” + i._2 + “*)”).mkString(“ “)

val query = parser.parse(queryString)

--

--

--

Adrian is a software engineer, passionate about elegant code, photography and writing. Connect @ nenuadrian.com

Love podcasts or audiobooks? Learn on the go with our new app.

CS371P Spring 2021 Week 9: Irena Lee

Jenkins Shared Libraries

How to file an issue

Kubernetes Vulnerability Scan

Data Warehouse Integration: Refining Your Customer Data Stack

Keywords To Remember “While” Learning To Code…

🌕The next generation NFT “DeMeta” — Interoperable, Editable, Evolvable

Best Charts for Fintech Apps

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrian M. Nenu 😺

Adrian M. Nenu 😺

Adrian is a software engineer, passionate about elegant code, photography and writing. Connect @ nenuadrian.com

More from Medium

GitHub Packages: Publish and Consume Artifacts of a Spring Gradle Project

Cracking encrypted Java applications using jhsdb (hotspot debugger)

Unit Testing Apache Camel

How Apache Camel Facilitates Your Integration Tasks: Part 2