Table of Contents | |
---|---|
In addition to the regular combination of tildes (~) and asterisk (*) wildcards, as explained elsewhere on this wiki the full text search also offers some additional features and helps to overcome the native limitations of datatype "Text".
A limitation of full-text search that regular wildcard search does not have is that it works solely on complete words and phrases. The example below, for instance, cannot be retrieved with a partial search string like ~"prob"
, while ~"probably"
should work.
Examples[edit]
Annotation to a property called "Has text" of datatype "Text"Holds text of arbitrary length1
... The principles of definition, the law of contradiction, the fallacy of arguing in a circle, the distinction between the essence and accidents of a thing or notion, between means and ends, between causes and conditions; also the division of the mind into the rational, concupiscent, and irascible elements, or of pleasures and desires into necessary and unnecessary --these and other great forms of thought are all of them to be found in the Republic, and were probably first invented by Plato. The greatest of all logical truths, and the one of which writers on philosophy are most apt to lose sight, the difference between words and things, has been most strenuously insisted on by him, although he has not always avoided the confusion of them in his own writings. ...
Phrase matching (both uppercase and lowercase)[edit]
Phrase matching is done by putting double quotes on either side of the phrase ("..."). This works for both uppercase and lowercase characters.
Query:
{{#ask: [[Has text::~"probably first invented by plato"]] |?Has text }}
Result:
Has text | |
---|---|
How to do searching with the full-text search | ... The principles of definition, the law of contradiction, the fallacy of arguing in a circle, the distinction between the essence and accidents of a thing or notion, between means and ends, between causes and conditions; also the division of the mind into the rational, concupiscent, and irascible elements, or of pleasures and desires into necessary and unnecessary --these and other great forms of thought are all of them to be found in the Republic, and were probably first invented by Plato. The greatest of all logical truths, and the one of which writers on philosophy are most apt to lose sight, the difference between words and things, has been most strenuously insisted on by him, although he has not always avoided the confusion of them in his own writings. ... |

Approximate matching within long texts[edit]
If the property is unknown, use two tildes (~~) instead of one:
Query:
{{#ask: [[~~probably first invented by Plato]] |format=broadtable |link=all |headers=show }}
Result:
How to do searching with the full-text search |
Wide proximity[edit]
Broad text search tries to match a string text without a specific property to broaden possible result matches. To initiate a fulltext match search specific an additional ~
will indicate to the QueryEngine
to use the fulltext index.
[[!~~ first invented by Plato]]
to be translated into the SQL-query(MATCH(t0.o_text) AGAINST ('-first invented by plato' IN BOOLEAN MODE) )
[[~~ first invented by Plato]]
to be translated into the SQL-query(MATCH(t0.o_text) AGAINST ('first invented by plato' IN BOOLEAN MODE) )
Search highlighting[edit]
Search highlighting2 which is done by adding the #-hl
formatter to the printout statement of the respective property.
Query:
{{#ask: [[Has text::~"probably first invented by plato"]] |?Has text#-hl }}
Result:
Has text | |
---|---|
How to do searching with the full-text search | ... The principles of definition, the law of contradiction, the fallacy of arguing in a circle, the distinction between the essence and accidents of a thing or notion, between means and ends, between causes and conditions; also the division of the mind into the rational, concupiscent, and irascible elements, or of pleasures and desires into necessary and unnecessary --these and other great forms of thought are all of them to be found in the Republic, and were probably first invented by Plato. The greatest of all logical truths, and the one of which writers on philosophy are most apt to lose sight, the difference between words and things, has been most strenuously insisted on by him, although he has not always avoided the confusion of them in his own writings. ... |

- All occurrences of strings included in the query statement will be highlighted as well, e.g. "by" in the above example.
- There is a difference between Plato (with an uppercase initial) in the original text and plato (as part of the query string).
More examples[edit]
References
- ^ Semantic MediaWiki: GitHub issue #1481 example
- ^ Semantic MediaWiki: GitHub pull request gh:smw:2253