Skip to content

SOLR advanced queries

Oleh Astappiev edited this page Oct 16, 2023 · 1 revision

Advanced Queries using SOLR

Fields :

Name Type Description Value
id string The id of this resource r_*, * stands for a integer
title text_general The title of this resource
source text_general The place where the resource is found YouTube, Vimeo, Flickr, Ipernity, facebook, Google, Bing, TED …
description text_general The description of this resource
location text_general The location where the resource (metadata) is stored
type text_general The type of this resource Video, Image…
format text_general The format of this resource image/jpeg, application/pdf …
comments text_general The comments of this resource a list of text, each text is a comment of the resource
tags text_general The tags of this resource a list of text, each text is a tag of the resource
groups int The groups to which this resource belongs a list of integer, each integer is a group id
author text_general The author of the resource
url string The url of the resource
machineDescription text_general The content extracted from files which are attached to this resource
ownerUserId int Id of the owner of this resource

All these fields are indexed and stored, which means users can search on all these fields.

Only tags, groups, comments are multivalued, which means they have more than one value.

When there are no fields specified in a query, the search will be in the following default fields with default boost(weight) : title, tags, description, comments, machineDescription.

Query Syntax :

The query is in Solr Query Syntax.

Here are some examples demonstrating the query syntax.

Keyword matching

  • Search for the word “bike” in the title field :

title:bike

  • Search for the phrase “ride bikes” in the title field :

title:”ride bikes”

  • Search for the word “bike” in title field AND the phrase “ride bikes” in the description field :

title:bike AND decription:”ride bikes”

  • Search for either the word “bike” in title field AND the phrase “ride bikes” in the description field, OR the word “sports” in the title field :

(title:bike AND decription:”ride bikes”) OR title:sports

  • Search for word “bike” and not “sports” in the title field :

title:bike –title:sports

Wildcard matching

  • Search for any word that starts with “pre” in the title field :

title:pre*

  • Search for any word that starts with “pre” and ends with “suf” in the title field :

title:pre*suf

Range searches

  • Search for resources belong to groups between group 10 and group 20 :

groups:[10 TO 20]

  • Search for resources belong to groups whose id are greater than or equal to 10 :

gourps:[10 TO *]

Boosts

Query-time boosts allow one to specify which terms/clauses are "more important".

  • Search word “bike” in both title field and description field, but title field with a higher boost :

title:bike^2.0 description:bike^1.0

Example Queries :

  • Find all resources in group 10 :

groups:10

  • Find all resources from the user with id 10 :

ownerUserId:10

  • Find the resource with the exact resource id 2328 :

Id:r_2328

  • Search for word “bike” only in field tags and comments :

tags:bike comments:bike

  • Search for word “bike” in title field, and only return Image resource :

title:bike AND type:Image

  • Search for word “bike” in title field, and only return resources from YouTube :

title:bike AND source:YouTube

Clone this wiki locally