PhiloLogic4’s query syntax has 5 basic operators:
token"token"1700-1750|, e.g. token | wordNOT, e.g. token.* NOT tokensThis syntax is the same, but interpreted slightly differently, for the two different types of text query fields: word search and metadata search.
Full-text word search is unique in having the concept of a “term”, which is either a single plain/quoted term,
or a group of plain/quoted terms joined by |, optionally followed by NOT and another term-like filter expression.
When specifying a query, one can select a query method to constrain the relation between terms, such as within k words or in the same sentence
within k words or in the same sentence, the phrase is one term: its words stay together, and the phrase counts as
one word for the distance, so "peuple français" souverain within 3 words finds souverain up to 3 words before
peuple or after français.OR can conjoin plain and quoted tokens, and precedes evaluation of phrase distance.NOT is a filter on a preceding term, but cannot stand alone: a.* NOT abalone is legal, NOT a.* is illegalIf you text collection contains lemma and/or word attribute information (usually in
lemma: such as in lemma:have. Regexes are permitted on the token portion of the search, e.g. lemma:constitut.*.
parce que) are stored with whitespace collapsed to underscores. Query them as lemma:parce_que, not lemma:parce que.word:attribute:attribute syntax such as in love:pos:NOUN. Regexes are permitted on the token portion of the search, e.g. lov.*:pos:NOUN.lemma: such as in lemma:love:pos:NOUN. Regexes are permitted on the token portion of the search, e.g. lemma:lov.*:pos:NOUN.charles:pos:PROPN:ner:PERS: the occurrences of charles that have them all. Regexes are permitted on the token portion here too, e.g. char.*:pos:PROPN:ner:PERS.Metadata values have a syntax of their own: the database’s word-search settings (query_parser_regex) don’t apply to them.
ascii_conversion) accents.
A word with hyphens or apostrophes, as jean-jacques, needs its parts side by side. Regexes are permitted, and match whole words."Les Révoltés de la ""Bounty""".1700-1750, -1750 or 1750-, work in numeric fields only. In text fields, - is part of a word.OR (or |) joins alternatives, preceding the implied Boolean AND.NOT excludes what follows, and may stand alone: contrat NOT social is legal, so is NOT rousseau.
Objects with no value are not excluded: NOT rousseau NOT NULL leaves them out too.NULL matches the objects with no value, NOT NULL those with one.1789, 1789-07 or 1789-07-14, and a year or a month matches all its days.
A range joins two dates with <=>, from the first day of one to the last of the other, as 1789<=>1790-06;
leave one out for no bound: <=>1790, 1789<=>. Dates separated by spaces are alternatives, as with OR.Metadata objects also have the unique property of recursion, which creates some unusual consequences for search semantics.
Searching for a div that has property NOT x does not guarantee that the result does not contain a child with property x,
or a parent with property x. This can often be handled at the database level by normalizing metadata to a single fine-grained layer,
but is tricky. Likewise, searches for NULL values in recursive objects will often return “virtual” philologic objects,
which don’t exist in the XML but are necessary for balanced tree arithmetic.
Basic regexp syntax, adapted from the egrep regular expression syntax.
. matches any single character except newline.[aeiou] or [a-z], but will only match a single character unless followed by one of the quantifiers below.* indicates that the regular expression should match zero or more occurrences of the previous character or bracketed group.+ indicates that the regular expression should match one or more occurrences of the previous character or bracketed group.? indicates that the regular expression should match zero or one occurrence of the previous character or bracketed group.
Thus, .* is an approximate “match anything” wildcard operator, rather than the more traditional (but less precise) * in many other search engines.