{"version":"1.0","provider_name":"Aeologic Blog","provider_url":"https:\/\/www.aeologic.com\/blog","title":"The Standard Query Parser - Ultimate Solr Guide - Aeologic Blog","type":"rich","width":600,"height":338,"html":"<blockquote class=\"wp-embedded-content\" data-secret=\"Xf9OiCrUcU\"><a href=\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide14-the-standard-query-parser\/\">The Standard Query Parser &#8211; Ultimate Solr Guide<\/a><\/blockquote><iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"https:\/\/www.aeologic.com\/blog\/ultimate-solr-guide14-the-standard-query-parser\/embed\/#?secret=Xf9OiCrUcU\" width=\"600\" height=\"338\" title=\"&#8220;The Standard Query Parser &#8211; Ultimate Solr Guide&#8221; &#8212; Aeologic Blog\" data-secret=\"Xf9OiCrUcU\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\"><\/iframe><script>\n\/*! This file is auto-generated *\/\n!function(d,l){\"use strict\";l.querySelector&&d.addEventListener&&\"undefined\"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!\/[^a-zA-Z0-9]\/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret=\"'+t.secret+'\"]'),o=l.querySelectorAll('blockquote[data-secret=\"'+t.secret+'\"]'),c=new RegExp(\"^https?:$\",\"i\"),i=0;i<o.length;i++)o[i].style.display=\"none\";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute(\"style\"),\"height\"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):\"link\"===t.message&&(r=new URL(s.getAttribute(\"src\")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener(\"message\",d.wp.receiveEmbedMessage,!1),l.addEventListener(\"DOMContentLoaded\",function(){for(var e,t,s=l.querySelectorAll(\"iframe.wp-embedded-content\"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute(\"data-secret\"))||(t=Math.random().toString(36).substring(2,12),e.src+=\"#?secret=\"+t,e.setAttribute(\"data-secret\",t)),e.contentWindow.postMessage({message:\"ready\",secret:t},\"*\")},!1)))}(window,document);\n\/\/# sourceURL=https:\/\/www.aeologic.com\/blog\/wp-includes\/js\/wp-embed.min.js\n<\/script>\n","thumbnail_url":"https:\/\/www.aeologic.com\/blog\/wp-content\/uploads\/2020\/06\/Standard-Query-in-solr.png","thumbnail_width":1080,"thumbnail_height":622,"description":"Solr\u2019s default Query Parser is also known as the \u201clucene\u201d 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\u2019s very intolerant of syntax errors, as compared with something like the&nbsp;DisMax&nbsp;query parser which is designed to throw as few errors as possible. Standard Query Parser Parameters In addition to the&nbsp;Common Query Parameters,&nbsp;Faceting Parameters,&nbsp;Highlighting Parameters, and&nbsp;MoreLikeThis Parameters, the standard query parser supports the parameters described in the table below.qDefines a query using standard query syntax. This parameter is mandatory.q.opSpecifies the default operator for query expressions. Possible values are &#8220;AND&#8221; or &#8220;OR&#8221;.dfSpecifies a default searchable field.sowSplit on whitespace. If set to&nbsp;true, text analysis is invoked separately for each individual whitespace-separated term. The default is&nbsp;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&nbsp;solrconfig.xml, or overridden by query-time values in the request. Standard Query Parser Response By default, the response from the standard query parser contains one&nbsp;&lt;result&gt;&nbsp;block, which is unnamed. If the&nbsp;debug&nbsp;parameter&nbsp;is used, then an additional&nbsp;&lt;lst&gt;&nbsp;block will be returned, using the name &#8220;debug&#8221;. This will contain useful debugging info, including the original query string, the parsed query string, and explain info for each document in the &lt;result&gt; block. If the&nbsp;explainOther&nbsp;parameter&nbsp;is also used, then additional explain info will be provided for all the documents matching that query. Specifying Terms for the Standard Query Parser A query to the standard query parser is broken up into terms and operators. There are two types of terms: single terms and phrases. A single term is a single word such as &#8220;test&#8221; or &#8220;hello&#8221; A phrase is a group of words surrounded by double quotes such as &#8220;hello dolly&#8221; Term Modifiers Solr supports a variety of term modifiers that add flexibility or precision, as needed, to searches. These modifiers include wildcard characters, characters for making a search &#8220;fuzzy&#8221; or more general, and so on. The sections below describe these modifiers in detail. Wildcard Searches Solr\u2019s standard query parser supports single and multiple character wildcard searches within single terms. Wildcard characters can be applied to single terms, but not to search phrases. Wildcard Search Type Special Character Example Single character (matches a single character) ? The search string&nbsp;te?t&nbsp;would match both test and text. Multiple characters (matches zero or more sequential characters) * The wildcard search:&nbsp;tes*&nbsp;would match test, testing, and tester. You can also use wildcard characters in the middle of a term. For example:&nbsp;te*t&nbsp;would match test and text.&nbsp;*est&nbsp;would match pest and test. Fuzzy Searches Solr\u2019s standard query parser supports fuzzy searches based on the Damerau-Levenshtein Distance or Edit Distance algorithm. Fuzzy searches discover terms that are similar to a specified term without necessarily being an exact match. To perform a fuzzy search, use the tilde ~ symbol at the end of a single-word term. For example, to search for a term similar in spelling to &#8220;roam,&#8221; use the fuzzy search: roam~ This search will match terms like roams, foam, &amp; foams. It will also match the word &#8220;roam&#8221; itself. An optional distance parameter specifies the maximum number of edits allowed, between 0 and 2, defaulting to 2. For example: roam~1 This will match terms like roams &amp; foam &#8211; but not foams since it has an edit distance of &#8220;2&#8221; Proximity Searches A proximity search looks for terms that are within a specific distance from one another. To perform a proximity search, add the tilde character ~ and a numeric value to the end of a search phrase. For example, to search for a &#8220;apache&#8221; and &#8220;jakarta&#8221; within 10 words of each other in a document, use the search: \"jakarta apache\"~10 The distance referred to here is the number of term movements needed to match the specified phrase. In the example above, if &#8220;apache&#8221; and &#8220;jakarta&#8221; were 10 spaces apart in a field, but &#8220;apache&#8221; appeared before &#8220;jakarta&#8221;, more than 10 term movements would be required to move the terms together and position &#8220;apache&#8221; to the right of &#8220;jakarta&#8221; with a space in between. Existence Searches An existence search for a field matches all documents where a value exists for that field. To query for a field existing, simply use a wildcard instead of a term in the search. field:* A field will be considered to &#8220;exist&#8221; if it has any value, even values which are often considered &#8220;not existent&#8221;. (e.g.,&nbsp;NaN,&nbsp;\"\", etc.) Range Searches A range search specifies a range of values for a field (a range with an upper bound and a lower bound). The query matches documents whose values for the specified field or fields fall within the range. Range queries can be inclusive or exclusive of the upper and lower bounds. Sorting is done lexicographically, except on numeric fields. For example, the range query below matches all documents whose&nbsp;popularity&nbsp;field has a value between 52 and 10,000, inclusive. popularity:[52 TO 10000] Range queries are not limited to date fields or even numerical fields. You could also use range queries with non-date fields: title:{Aida TO Carmen} This will find all documents whose titles are between Aida and Carmen, but not including Aida and Carmen. The brackets around a query determine its inclusiveness. Square brackets&nbsp;[&nbsp;&amp;&nbsp;]&nbsp;denote an inclusive range query that matches values including the upper and lower bound. Curly brackets&nbsp;{&nbsp;&amp;&nbsp;}&nbsp;denote an exclusive range query that matches values between the upper and lower bounds, but excluding the upper and lower bounds themselves. You can mix these types so one end of the range is inclusive and the other is exclusive. Here\u2019s an example:&nbsp;count:{1 TO 10] Wildcards,&nbsp;*, can also be used for either or both endpoints to specify an open-ended range query. This is a&nbsp;divergence from Lucene\u2019s Classic Query Parser. field:[* TO 100]&nbsp;finds all field values less than or equal to 100. field:[100 TO *]&nbsp;finds all field values greater than or equal to 100. field:[* TO *]&nbsp;finds any document with a [&hellip;]"}