Skip to content
Menu
e-lo [IT Engineer life]
  • Home
    • Note
  • Database
    • T-SQL
    • SQL Server quick
    • SQL server docs
    • MySql quick sheet
    • Postgre
    • InfluxDB
  • Programming
    • MS Azure Powershell
    • MS Azure Command-Line Interface (CLI) doc
    • Python Docs
    • Python Logging
    • Python-cheat-sheet
    • Git-guide
  • Azure
    • MS Windows virtual machines in Azure
    • MS ARM Docs
    • MS ARM Template Docs
    • MS ARM Functions
    • MS Bicep+ARM
    • MS ARM Tutorial
    • MS Deployment scripts (intern/extern)
    • MS Virtual Network
  • Az-nutshell
    • ms-technology-choices-compute-decision-tree
    • ms-data-store-decision-tree
    • ms-data-explorer
    • ms-storage-explorer
    • ms-azure-sql
    • ms-common-data-services
    • ms-azure-mysql-daas
    • ms-sla
    • az paas
    • az glossary-quicksheet
    • az-test-vm-script-quickguide
  • Linux
    • Top CMD’s
    • Useful CMD Linux
    • ss64 Linux
    • Ubuntu
    • 30 things Ubuntu 18.04
    • Bootable Ubuntu USB
    • LinuxFilesystemTreeOverview
  • Sys Admin
    • System Administrator
    • Sys News
  • Zen
    • Not thinking about anything is Zen
e-lo [IT Engineer life]

Apache Solr 7.5 The Standard Query Parser focus searching

Posted on November 3, 2018November 7, 2018 by espenk

http://lucene.apache.org/solr/guide/7_5/the-standard-query-parser.html

Solr’s default Query Parser is also known as the “lucene” parser.

The key advantage of the standard query parser is that it supports a robust and fairly intuitive syntax allowing you to create a variety of structured queries. The largest disadvantage is that it’s very intolerant of syntax errors, as compared with something like the DisMax query parser which is designed to throw as few errors as possible.

Standard Query Parser Parameters

In addition to the Common Query Parameters, Faceting Parameters, Highlighting Parameters, and MoreLikeThis Parameters, the standard query parser supports the parameters described in the table below.

  • q: Defines a query using standard query syntax. This parameter is mandatory.
  • q.op: Specifies the default operator for query expressions, overriding the default operator specified in the Schema. Possible values are “AND” or “OR”.
  • df: Specifies a default field, overriding the definition of a default field in the Schema.
  • sow: Split on whitespace. If set to true, text analysis is invoked separately for each individual whitespace-separated term. The default is false; whitespace-separated term sequences will be provided to text analysis in one shot, enabling proper function of analysis filters that operate over term sequences, e.g., multi-word synonyms and shingles.

Default parameter values are specified in solrconfig.xml, or overridden by query-time values in the request.

We are going to focus on the q parameter for searching.

The code is at https://github.com/spawnmarvel/solrhttp

So I have changed the test-data a bit, format now is:

9991;Item-9991;Fuel Area 9991;System 4
9992;Item-9992;Monitor Housing 9992;System 4
9993;Item-9993;Fuel Gate 9993;System 4
9994;Item-9994;Heat Area 9994;System 4
9995;Item-9995;Valve Ice 9995;System 4
9996;Item-9996;Oil Water 9996;System 4
9997;Item-9997;Door High 9997;System 4
9998;Item-9998;TurbinEngine Low 9998;System 4
9999;Item-9999;Fuel Area 9999;System 4

And we have 10000 items stored in Solr (ref generate_test_data()).

Search using run_search.py

Get item where id = 1:

http://localhost:8983/solr/newcore/select?q=id:1

Get items in range 9980-9982:

http://localhost:8983/solr/newcore/select?q=id:[9980 TO 9982]

Get item with desc like Gas and return max 7 rows:
http://localhost:8983/solr/newcore/select?q=desc:*Gas*&rows=7
Solr Wiki:
https://wiki.apache.org/solr/CommonQueryParameters

 

Experiment with the Querybuilder in Solr and you will learn and also get the url ready for your application:

Happy index and happy searching.

 

 

 

RSS Azure

  • Scale your cloud-native apps and accelerate app modernization with Azure, the best cloud for your apps May 24, 2022

RSS RabbitMQ

  • RabbitMQ 3.8.15 release

RSS Python

  • PEP 691: JSON-based Simple API for Python Package Indexes May 4, 2022

Tags

5 min (26) Ansible (1) ARM (10) azure (40) cmd (3) Django (4) Docker (1) e-lo (2) Flask (2) Github (9) Grafana (2) Information (7) Information Retrieval (13) JAVA (1) kivy (2) Kotlin (6) linux (15) mobile (2) Natural Language Prossesing (NLP) (2) Net.Core (1) Networking and Security (6) OPC (2) PEP8 (1) Philosophy (3) Python (47) Python Networking and Security (5) Reason (2) RMQ (3) Solr (11) Sql (10) Uncategorized (2) VSC (1) Warframe (2) WMVARE (4) Zabbix (7)

Recent Posts

  • 5 min Logic App Storage Table
  • 5 min Logic App PSQL
  • 5 min Logic App
  • 5 MIN Azure Data Explorer
  • TODO Build a Hash Table in Python With TDD Real Python

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Photo by Markus Spiske from Pexels "Matrix"

©2022 e-lo [IT Engineer life] | Powered by WordPress & Superb Themes