module:store/SolrQuery

module:store/SolrQuery

The SolrQuery class provides a way to create a query by chaining method calls according to the builder pattern. For example:

const sq = es.newSolrQuery().title("some title").rdfType("http://example.com/Person")

The example yields a search for entries that have a title that contains "some title" and a rdf:type of "http://example.com/Person" expressed in the metadata. To execute the query you can either ask for a SearchList and then call getEntries (or forEach):

const sl = sq.list();
sl.getEntries().then((entryArr) => {// Do something })

Or you use the abbreviated version where you just call getEntries directly (or forEach) on the SolrQuery:

sq.getEntries()

The majority of the methods work the same way, that is they take two values, a value and a possible negation flag. The value can be an array corresponding to a disjunction and if the flag is set true the search string will be constructed to search for the negation of the provided value. For example, if a graph type in the form of an array containing List and User is provided together with a negation boolean set to true, the query will search for anything but lists and users:

sq.graphType([types.GT_LIST, types.GT_USER], true)

Supported methods on the solr object correspond in large to the available solr fields documented at, some method names are different to avoid dots: https://code.google.com/p/entrywiki/KnowledgeBaseSearch

There is also a special method (getQuery) for getting the query as a string that is used by EntryStore API behind the scenes, you can safely ignore this method.

Constructor

new (require("store/SolrQuery"))(entrystore)

Source:
Parameters:
Name Type Description
entrystore EntryStore

Members

modifiers :Map.<string, any>

Source:
Type:
  • Map.<string, any>

params :Map.<string, *>

Source:
Type:
  • Map.<string, *>

Methods

admin(val, modifier) → {SolrQuery}

Source:

Matches only entries with explicitly ACL stating user(s) has admin rights

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

all(val, modifier) → {SolrQuery}

Source:

Matches title, description and tags, multivalue, cannot be sorted on.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

and(structure) → {SolrQuery}

Source:

Provide a query in the form of an object structure where the toplevel attributes are conjunctive (AND:ed together). The following example will query for things that are typed as vedgetables OR typed as fruit AND has a title that contains the word 'orange': query.disjunctive().rdfType('ex:Vedgetable).and({ rdfType: 'ex:Fruit', title: 'Orange', });

Note, the name of the method ('and') does not refers to how the object structure is combined with the rest of the query, only how the inner parts of the object structure is combined. In this example we have change the toplevel behaviour of the query to become disjunctive (being OR:ed together), this is to make the query more representative since there is no need for the grouping of the object structure otherwise.

Parameters:
Name Type Description
structure Object
Returns:
Type
SolrQuery

context(context, modifier) → {SolrQuery}

Source:

Matches only entries within specified context(s)

Parameters:
Name Type Default Description
context string | Context

either a contextId, the resourceURI for a

  • * context, a Context instance or an array containing any of those. In case of a
    
  • * string, either directly or within the array and it starts with 'http' it is assumed it is
    
  • * the resourceURI of the context, otherwise the context is assumed to be a contextId.
modifier true | false | string null
Returns:
Type
SolrQuery

contributors(val, modifier) → {SolrQuery}

Source:

Matches all contributors (in the entry information graph) expressed via their resourceURIs.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

created(val, modifier) → {SolrQuery}

Source:

Matches entries that are created at a specific date or in a range. Ranges must be given as strings as [2010-01-01T00:00:00Z TO *].

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

createdRange(from, to, modifier) → {SolrQuery}

Source:

Utility function to create a range expression for the created function.

Parameters:
Name Type Default Description
from Date

no lower range restriction if undefined or null is passed

to Date

no upper range restriction if undefined or null is passed

modifier true | false | string null
Returns:
Type
SolrQuery

creator(val, modifier) → {SolrQuery}

Source:

Matches all creators (in the entry information graph) expressed via their resourceURIs.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

dateProperty(predicate, object, modifier, related) → {SolrQuery}

Source:

Matches specific property value combinations when the value is an integer. Note that the integer values are single value per property and can be used for sorting. Ranges are allowed as strings, for instance [* TO 2010-01-01T00:00:00Z].

Parameters:
Name Type Default Description
predicate string
object string | array
modifier true | false | string
related boolean false

will search in related properties if true, default is false

Returns:
Type
SolrQuery

datePropertyRange(predicate, from, to, modifier, related) → {SolrQuery}

Source:

Utility function for creating a date range for dateProperty.

Parameters:
Name Type Default Description
predicate string
from Date
to Date
modifier true | false | string
related boolean false

will search in related properties if true, default is false

Returns:
Type
SolrQuery

description(val, modifier) → {SolrQuery}

Source:

Matches all descriptions in all languages, multivalued, cannot be sorted on. Includes dc:description, dcterms:description, rdfs:comment

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

disjunctive() → {SolrQuery}

Source:

Tell the query construction to make top level fields disjunctive rather than conjunctive. For example

es.newSolrQuery().disjunctive().title("banana").description("tomato")

Will search for entries that have either a "banana" in the title or "tomato" in the description rather than entries that have both which is the default.

Returns:
Type
SolrQuery

disjunctiveProperties() → {SolrQuery}

Source:

Tell the query construction to make the fields added via the property methods (uriProperty, literalProperty and integerProperty) to be disjunctive rather than conjunctive. For example:

es.newSolrQuery().disjunctiveProperties().literalProperty("dcterms:title", "banana")
     .uriProperty("dcterms:subject", "ex:Banana");

Will search for entries that have either a "banana" in the title or a relation to ex:Banana via dcterms:subject. The default, without disjunctiveProperties being called is to create a conjunction, i.e. AND them together.

Returns:
Type
SolrQuery

entryType(val, modifier) → {SolrQuery}

Source:

Matches entries with the given entry type, use the values in types, e.g. sq.entryType(types.ET_LINK).

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

forEach(func) → {promise}

Source:
See:
  • {List.forEach}
Parameters:
Name Type Description
func
Returns:
Type
promise

getEntries(page) → {Promise.<Array.<Entry>>}

Source:
See:
  • {List.getEntries}
Parameters:
Name Type Description
page
Returns:

the promise will return an entry-array.

Type
Promise.<Array.<Entry>>

getLimit() → {string|number}

Source:

Gets the pagination limit if it set.

Returns:
Type
string | number

(protected) getQuery() → {string}

Source:

Produces the actual query to the EntryStore API.

Returns:
Type
string

graphType(val, modifier) → {SolrQuery}

Source:

Matches entries with the given graph type, use the values in types, e.g. sq.entryType(types.GT_USER).

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

integerFacet(predicate, relatedopt) → {SolrQuery}

Source:

Request to include integer facets for the given predicate

Parameters:
Name Type Attributes Default Description
predicate string
related boolean <optional>
false

whether the facet is on the related predicates, default is false

Returns:
Type
SolrQuery

integerProperty(predicate, object, modifier, related) → {SolrQuery}

Source:

Matches specific property value combinations when the value is an integer. Note that the integer values are single value per property and can be used for sorting. Ranges are allowed as strings, for instance [0 TO 100] or [0 TO *] for all positive integers.

Parameters:
Name Type Default Description
predicate string
object string | array
modifier true | false | string
related boolean false

will search in related properties if true, default is false

Returns:
Type
SolrQuery

integerPropertyRange(predicate, from, to, related) → {SolrQuery}

Source:

Utility function for creating a integer range for integerProperty.

Parameters:
Name Type Default Description
predicate string
from string | number

if undefined no lower bound will be created, corresponds to *

to string | number

if undefined no upper bound will be created, corresponds to *

related boolean false

will search in related properties if true, default is false

Returns:
Type
SolrQuery

lang(val, modifier) → {SolrQuery}

Source:

Matches the language (as a literal) of the resource, single value, can be used for sorting? Includes dc:language, dcterms:language

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

limit(limit) → {SolrQuery}

Source:

Sets the pagination limit.

Parameters:
Name Type Description
limit string | number
Returns:
Type
SolrQuery

list(asyncCallType) → {SearchList}

Source:

Construct a SearchList fro this SolrQuery.

Parameters:
Name Type Description
asyncCallType
Returns:
Type
SearchList

lists(val, modifier) → {SolrQuery}

Source:

Matches only entries that are part of the given lists, identified via their resourceURIs.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

literalFacet(predicate, relatedopt) → {SolrQuery}

Source:

Request to include literal facets for the given predicate

Parameters:
Name Type Attributes Default Description
predicate string
related boolean <optional>
false

whether the facet is on the related predicates, default is false

Returns:
Type
SolrQuery

literalProperty(predicate, object, modifier, indexTypeopt, relatedopt) → {SolrQuery}

Source:

Matches specific property value combinations.

Parameters:
Name Type Attributes Default Description
predicate string
object string | array
modifier true | false | string
indexType text | string <optional>
ngram

'ngram' corresponds to partial string matching, string corresponds to exact string matching and text corresponds to word matching.

related boolean <optional>
false

will search in related properties if true, default is false

Returns:
Type
SolrQuery

metadataRead(val, modifier) → {SolrQuery}

Source:

Matches only entries with explicitly ACL stating user(s) has metadata read rights

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

metadataWrite(val, modifier) → {SolrQuery}

Source:

Matches only entries with explicitly ACL stating user(s) has metadata write (and read) rights

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

modified(val, modifier) → {SolrQuery}

Source:

Matches entries that are modified at a specific date or in a range. Ranges are given as strings as [2010-01-01T00:00:00Z TO *].

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

modifiedRange(from, to, modifier) → {SolrQuery}

Source:

Utility function to create a range expression for the modified function.

Parameters:
Name Type Default Description
from Date

no lower range restriction if undefined or null is passed

to Date

no upper range restriction if undefined or null is passed

modifier true | false | string null
Returns:
Type
SolrQuery

objectLiteral(val, modifier) → {SolrQuery}

Source:

Matches all literals in object position in the metadata.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

objectUri(val, modifier) → {SolrQuery}

Source:

Matches all URIs in object position in the metadata.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

offset(offset) → {SolrQuery}

Source:

Set an explicit offset.

Parameters:
Name Type Description
offset string | number
Returns:
Type
SolrQuery

or(structure) → {SolrQuery}

Source:

Provide a query in the form of an object structure where the toplevel attributes are disjunctive (OR:ed together). The following example will query for things that are typed as vedgetables AND have the word 'tomato' in either the title OR description: query.rdfType('ex:Vedgetable).or({ title: 'tomato', description: 'tomato' });

Note, the name of the method ('or') does not refers to how the object structure is combined with the rest of the query, only how the inner parts of the object structure is combined. To change the toplevel behaviour of the query from an and to an or, use the disjunctive method.

Parameters:
Name Type Description
structure Object
Returns:
Type
SolrQuery

predicate(val, modifier) → {SolrQuery}

Source:

Matches all URIs in predicate position in the metadata.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

publicRead(isPublic) → {SolrQuery}

Source:

Matches only public entries. Warning, individual entrys public flag is inherited from surrounding context and if the context ACL is updated the entrys are not reindexed automatically. Hence, this flag may be incorrect.

Parameters:
Name Type Default Description
isPublic true | false true
Returns:
Type
SolrQuery

rdfType(rdfType, modifier) → {SolrQuery}

Source:

Matches all types of the resourceURI, i.e. all URIs pointed to via rdf:type from the resourceURI.

Parameters:
Name Type Default Description
rdfType string | array
modifier true | false | string null
Returns:
Type
SolrQuery

resource(val, modifier) → {SolrQuery}

Source:

Matches the resourceURI of the entry.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

resourceRead(val, modifier) → {SolrQuery}

Source:

Matches only entries with explicitly ACL stating user(s) has resource read rights

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

resourceType(val, modifier) → {SolrQuery}

Source:

Matches entries with the given resource type, use the values in types, e.g. sq.entryType(types.RT_INFORMATIONRESOURCE).

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

resourceWrite(val, modifier) → {SolrQuery}

Source:

Matches only entries with explicitly ACL stating user(s) has resource write (and read) rights

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

sort(sort) → {SolrQuery}

Source:

The parameter "sort" can be used for Solr-style sorting, e.g. "sort=title+asc,modified+desc". The default sorting value is to sort after the score (relevancy) and the modification date. All string and non-multi value fields can be used for sorting, this basically excludes title, description and keywords, but allows sorting after e.g. title.en. If no sort is explicitly given the default sort string used is "score+asc".

Parameters:
Name Type Description
sort String

a list of fields together with '+asc' or '+desc', first field has the highest priority when sorting.

Returns:
Type
SolrQuery

status(val, modifier) → {SolrQuery}

Source:

Matches entries with with specific status (expressed in entry information graph)

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

subject(val, modifier) → {SolrQuery}

Source:

Matches all URIs in subject position in the metadata, except the resourceURI.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

tagLiteral(val, modifier) → {SolrQuery}

Source:

Matches all tags literals in all languages, multivalued, cannot be sorted on. Includes dc:subject, dcterms:subject, dcat:keyword and lom:keyword

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

tagURI(val, modifier) → {SolrQuery}

Source:

Matches all tag URIs, multivalued, cannot be sorted on. Includes dc:subject, dcterms:subject

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

title(val, modifier) → {SolrQuery}

Source:

Matches all titles in all languages, multivalued, cannot be sorted on. Includes dc:title, dcterms:title, skos:prefLabel, skos:altLabel, skos:hiddenLabel, rdfs:label, foaf:name.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

title_lang()

Source:
Deprecated:
  • Yes

titleWithLanguage(title, language) → {SolrQuery}

Source:

If a title has a language set, a dynamic field is created with the pattern "title.en", without multi value support. This is used in the context of sorting.

Parameters:
Name Type Description
title String

the title to search for

language String

the language of the title for instance "en".

Returns:
Type
SolrQuery

uri(val, modifier) → {SolrQuery}

Source:

Matches the entryURI of the entry.

Parameters:
Name Type Default Description
val string | array
modifier true | false | string null
Returns:
Type
SolrQuery

uriFacet(predicate, relatedopt) → {SolrQuery}

Source:

Request to include URI facets for the given predicate

Parameters:
Name Type Attributes Default Description
predicate string
related boolean <optional>
false

whether the facet is on the related predicates, default is false

Returns:
Type
SolrQuery

uriProperty(predicate, object, modifier, related) → {SolrQuery}

Source:

Matches specific property value combinations when the value is an uri.

Parameters:
Name Type Default Description
predicate string
object string | array
modifier true | false | string
related boolean false

will search in related properties if true, default is false

Returns:
Type
SolrQuery