One, foreword

In the last section we talked about how to build the Solr service, and how to use it as a full-text search engine is also critical. Solr has its own set of queries, so we need to spend extra time learning its set of patterns.

Start the solr

solr start
Copy the code

Set the heap size, because a full import may cause the heap to overflow.

Set heap size to 1 gb at startup
solr start -m 1g
Copy the code

The solr

solr stop -p <port>
Copy the code

Enter Solr admin interface, there will be a lot of query parameters for you to use, then let’s understand the specific use of each parameter.

Second, parameters list

Solr Query parameters

Parameter names describe The sample
q The main query parameters, separated by colons, are the field name on the left, the value on the right, and all the query parameters are *:* age:20
fq Filter query parameters. You can add multiple parameters. The format is the same as q Name: Korea
sort Sort type. The fields are separated by Spaces, and multiple fields are separated by commas. The sort value is desc or ASC id desc,name asc
start Start position, default is 0 1
rows Gets the number of records. Default is 10 100
fl Returns the specified fields, separated by commas id,name
df The default query field, q and fq can only enter the value after setting
Raw Query Parameters
wt Returns the result in json, XML, Python, Ruby, etc json
indent off Returns whether the result is indent, by default, or not
debugQuery Check whether debugging information is displayed
dismax
edismax
hl Turn on highlighting
hl.fl The field to highlight
hl.simple.pre The highlighted prefix
hl.simple.post The suffix highlighted

3. Example operation

  • Parameter [q]

  • Parameters [FQ]

  • Parameter [sort]

  • Parameters [start, rows]

  • Parameters [FL]

  • Parameter [df]

  • Parameter [wt]

  • Parameter [indent off]

Stay tuned for the next section where I’ll explain how to use Solr in your Own Java projects.