mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
Fix exact search
Previously a query was only parsed by lucene as it is, if the query contained a colon (:) or a wildcard character (*). With this, every query gets parsed as it is, as long as there is one operator contained inside the query (colon, quotation marks, logical operators, ...). These are called "expert queries". All other queries are still processed as "simple queries" where every part of the query is extended with a wildcard operator. Addtionally the user is now getting feedback for every search, if the query is a simple query or an expert query. The syntax documentation got also extended with the quotation mark operator and the definition of the two query types. Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
@@ -25,21 +25,10 @@ export default `## Modifikatoren
|
||||
|
||||
Hinweis: Sie können keine Wildcards als erstes Zeichen einer Suche verwenden.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Beispiel</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>? - Einzelzeichen-Wildcard</td>
|
||||
<td>Ultimate?Repo - findet z.B. Ultimate-Repo, Ultimate Repo, Ultimate+Repo</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>* - mehrstelliger Platzhalter</td>
|
||||
<td>Ultimat*y - findet z.B. Ultimate Repository, Ultimates-Spezial-Repository, Ultimate</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|Definition|Beispiel|
|
||||
|----------|--------|
|
||||
|? - Einzelzeichen-Wildcard|"Ultimate?Repo" - findet z.B. \`Ultimate-Repo\`, \`Ultimate Repo\`, \`Ultimate+Repo\`|
|
||||
|* - mehrstelliger Platzhalter|"Ultimat*y" - findet z.B. \`Ultimate Repository\`, \`Ultimates-Spezial-Repository\`, \`Ultimate\`|
|
||||
|
||||
### Bereiche
|
||||
|
||||
@@ -47,37 +36,18 @@ Bereichsabfragen ermöglichen den Abgleich von Dokumenten, deren Feldwerte zwisc
|
||||
|
||||
Bereiche sind nicht auf numerische Felder beschränkt.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Beispiel</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[ … TO … ] - inklusiver Bereich</td>
|
||||
<td>creationDate:[1609459200000 TO 1612137600000] – findet z.B. Repositories, die zwischen dem 01.01.2021 und dem 01.02.2021 angelegt wurden.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{… TO …} - ausschließender Bereich</td>
|
||||
<td>name:{Aida TO Carmen} – findet Namen zwischen Aida und Carmen, jedoch ohne die beiden Namen einzuschließen.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|Definition|Beispiel|
|
||||
|----------|--------|
|
||||
|[ … TO … ] - inklusiver Bereich|"creationDate:[1609459200000 TO 1612137600000]" – findet z.B. Repositories, die zwischen dem 01.01.2021 und dem 01.02.2021 angelegt wurden|
|
||||
|{… TO …} - ausschließender Bereich|"name:{Aida TO Carmen}" – findet Namen zwischen Aida und Carmen, jedoch ohne die beiden Namen einzuschließen|
|
||||
|
||||
## Boosten
|
||||
|
||||
Mit dem Boosting können Sie die Relevanz eines Dokuments steuern, indem Sie seinen Term verstärken.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Beispiel</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>term^Zahl</td>
|
||||
<td>ultimate^2 repository – erhöht die Relevanz von „ultimate"</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|Definition|Beispiel|
|
||||
|----------|--------|
|
||||
|Begriff^Zahl|"ultimate^2 repository" – erhöht die Relevanz von \`ultimate\`|
|
||||
|
||||
Standardmäßig ist der Boost-Faktor 1. Obwohl der Boost-Faktor positiv sein muss, kann er kleiner als 1 sein (z. B. 0,2)
|
||||
|
||||
@@ -88,40 +58,27 @@ Standardmäßig werden Repository-Namen um 1,5 und Namespace-Namen um 1,25 geboo
|
||||
Hinweis: Logische Operatoren müssen in Großbuchstaben eingegeben werden (z. B. „AND").
|
||||
|
||||
|Operator|Definition|Beispiel|
|
||||
|--|--|--|
|
||||
|AND|Beide Terme müssen enthalten sein|Ultimate AND Repository – findet z.B. Ultimate Repository, Ultimate Special Repository|
|
||||
|OR|Mindestens einer der Terme muss enthalten sein|Ultimate OR Repository – findet z.B.. Ultimate Repository, Ultimate User, Special Repository|
|
||||
|NOT|Der nachfolgende Term darf nicht enthalten sein, „!" kann alternativ verwendet werden|Ultimate NOT Repository – findet z.B.. Ultimate user, nicht jedoch z.B. Ultimate Repository|
|
||||
|–|Schließt den folgenden Term von der Suche aus|Ultimate Repository -Special – findet z.B. Ultimate Repository, schließt z.B. Ultimate Special Repository aus|
|
||||
|+ |Der folgende Term muss enthalten sein|Ultimate +Repository – findet z.B. my Repository, Ultimate Repository| </tr>
|
||||
|--------|----------|--------|
|
||||
|AND|Beide Terme müssen enthalten sein|"Ultimate AND Repository" – findet z.B. \`Ultimate Repository\`, \`Ultimate Special Repository\`|
|
||||
|OR|Mindestens einer der Terme muss enthalten sein|"Ultimate OR Repository" – findet z.B. \`Ultimate Repository\`, \`Ultimate User\`, \`Special Repository\`|
|
||||
|NOT|Der nachfolgende Term darf nicht enthalten sein, „!" kann alternativ verwendet werden|"Ultimate NOT Repository" – findet z.B. \`Ultimate user\`, nicht jedoch z.B. \`Ultimate Repository\`|
|
||||
|–|Schließt den folgenden Term von der Suche aus|"Ultimate Repository -Special" – findet z.B. \`Ultimate Repository\`, schließt z.B. \`Ultimate Special Repository\` aus|
|
||||
|+|Der folgende Term muss enthalten sein|"Ultimate +Repository" – findet z.B. \`my Repository\`, \`Ultimate Repository\`|
|
||||
|
||||
## Gruppieren
|
||||
|
||||
Die Suche unterstützt die Verwendung von Klammern zur Gruppierung von Begriffen, um Teilabfragen zu bilden. Dies kann sehr nützlich sein, wenn Sie die boolesche Logik für eine Abfrage steuern möchten.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Beispiel</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>() – Terme zwischen den Klammern werden gruppiert</td>
|
||||
<td>(Ultimate OR my) AND Repository – findet z.B.. Ultimate Repository, my Repository, schließt z.B. Super Repository. Entweder "Ultimate" oder “My” müssen im Ergebnis existieren, “Repository” muss immer enthalten sein.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|Definition|Beispiel|
|
||||
|----------|--------|
|
||||
|() – Terme zwischen den Klammern werden gruppiert|"(Ultimate OR my) AND Repository" – findet z.B. \`Ultimate Repository\`, \`my Repository\`, schließt z.B. Super Repository. Entweder "Ultimate" oder "My" müssen im Ergebnis existieren, "Repository" muss immer enthalten sein|
|
||||
|
||||
## Phrasen
|
||||
|
||||
## Umgang mit Sonderzeichen
|
||||
Eine Phrase ist eine Gruppe von Begriffen in einer bestimmten Reihenfolge. Falls man nach einer bestimmten Phrase suchen will, dann kann der \`"\`-Operator genutzt werden.
|
||||
|
||||
Die Suche unterstützt Sonderzeichen, die Teil der Abfragesyntax sind. Die aktuellen Sonderzeichen der Liste sind
|
||||
|Definition|Beispiel|
|
||||
|----------|--------|
|
||||
|"" - Begriffe innerhalb der Anführungszeichen werden als Phrase gesucht|"Ultimate Repository" – findet \`Ultimate Repository\` aber nicht \`Repository Ultimate\`, \`Ultimate\` oder \`Repository\`|
|
||||
|
||||
+ − && || ! ( ) { } [ ] ^ " ~ * ? : \ /
|
||||
|
||||
Um diese Zeichen zu nutzen, verwenden Sie „\" vor dem jeweiligen Zeichen. Um zum Beispiel nach (1+1):2 zu suchen, verwenden Sie diese Abfrage:
|
||||
|
||||
\(1\+1\)\:2
|
||||
|
||||
Partiell übersetzt mit www.DeepL.com/Translator (kostenlose Version)
|
||||
|
||||
Quelle [https://javadoc.io/static/org.apache.lucene/lucene-queryparser/8.9.0/org/apache/lucene/queryparser/classic/package-summary.html#package.description](https://javadoc.io/static/org.apache.lucene/lucene-queryparser/8.9.0/org/apache/lucene/queryparser/classic/package-summary.html#package.description)`;
|
||||
`;
|
||||
|
||||
@@ -25,21 +25,10 @@ export default `### Modifiers
|
||||
|
||||
Note: You can not use wildcards as the first character of a search.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Example</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>? - single character Wildcard</td>
|
||||
<td>Ultimate?Repo – finds e.g. Ultimate-Repo, Ultimate Repo, Ultimate+Repo</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>* - multiple character Wildcard</td>
|
||||
<td>Ultimat*y - finds e.g. Ultimate Repository, Ultimate-Special-Repository, Ultimately</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|Definition|Example|
|
||||
|----------|-------|
|
||||
|? - single character Wildcard|"Ultimate?Repo" – finds e.g. \`Ultimate-Repo\`, \`Ultimate Repo\`, \`Ultimate+Repo\`|
|
||||
|* - multiple character Wildcard|"Ultimat*y" - finds e.g. \`Ultimate Repository\`, \`Ultimate-Special-Repository\`, \`Ultimately\`|
|
||||
|
||||
### Ranges
|
||||
|
||||
@@ -47,37 +36,18 @@ Range Queries allow one to match documents whose field(s) values are between the
|
||||
|
||||
Ranges are not reserved to numerical fields.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Example</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>[ … TO … ] - inclusive range</td>
|
||||
<td>creationDate:[1609459200000 TO 1612137600000] – finds e.G. repositories created between 2021-01-01 and 2021-02-01 </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{… TO …} - exclusive range</td>
|
||||
<td>name:{Aida TO Carmen} – finds e.G. repositories with names between Aida and Carmen, excluding these to values.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|Definition|Example|
|
||||
|----------|-------|
|
||||
|[ … TO … ] - inclusive range|"creationDate:[1609459200000 TO 1612137600000]" – finds e.G. repositories created between 2021-01-01 and 2021-02-01|
|
||||
|{… TO …} - exclusive range|"name:{Aida TO Carmen}" – finds e.G. repositories with names between Aida and Carmen, excluding these to values|
|
||||
|
||||
### Boosting
|
||||
|
||||
Boosting allows you to control the relevance of a document by boosting its term.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Example</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>term^number</td>
|
||||
<td>ultimate^2 repository – makes the term "ultimate" more relevant. </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|Definition|Example|
|
||||
|----------|-------|
|
||||
|term^number|"ultimate^2 repository" – makes the term \`ultimate\` more relevant|
|
||||
|
||||
By default, the boost factor is 1. Although the boost factor must be positive, it can be less than 1 (e.g. 0.2)
|
||||
|
||||
@@ -87,39 +57,28 @@ By default Repository names are boosted by 1.5, namespace by 1.25.
|
||||
|
||||
Note: Logical Operators must be entered in upper case (e.g. "AND").
|
||||
|
||||
|Operator |Definition|Example|
|
||||
|------------|--|--|
|
||||
|AND|Both terms must be included|\`Ultimate AND Repository\` – finds e.g. Ultimate Repository, Ultimate Special Repository|
|
||||
|OR |At least one of the terms must be included|Ultimate OR Repository – finds e.g. Ultimate Repository, Ultimate User, Special Repository|
|
||||
|NOT |Following term may not be included, "!" may be used alternatively|Ultimate NOT Repository – finds e.g. Ultimate user, excludes e.g. Ultimate Repository|
|
||||
|– |Excludes following term from search|Ultimate Repository -Special – finds e.g. Ultimate Repository, excludes e.g. Ultimate Special Repository|
|
||||
|+ |Following term must be included|Ultimate +Repository – finds e.g. my Repository, Ultimate Repository|
|
||||
|Operator|Definition|Example|
|
||||
|--------|----------|-------|
|
||||
|AND|Both terms must be included|"Ultimate AND Repository" – finds e.g. \`Ultimate Repository\`, \`Ultimate Special Repository\`|
|
||||
|OR|At least one of the terms must be included|"Ultimate OR Repository" – finds e.g. \`Ultimate Repository\`, \`Ultimate User\`, \`Special Repository\`|
|
||||
|NOT|Following term may not be included, "!" may be used alternatively|"Ultimate NOT Repository" – finds e.g. \`Ultimate user\`, excludes e.g. \`Ultimate Repository\`|
|
||||
|–|Excludes following term from search|"Ultimate Repository -Special" – finds e.g. \`Ultimate Repository\`, excludes e.g. \`Ultimate Special Repository\`|
|
||||
|+|Following term must be included|"Ultimate +Repository" – finds e.g. \`my Repository\`, \`Ultimate Repository\`|
|
||||
|
||||
## Grouping
|
||||
|
||||
Search supports using parentheses to group clauses to form sub queries. This can be very useful if you want to control the boolean logic for a query.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Definition</th>
|
||||
<th>Example</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>() – terms inside parentheses are grouped together</td>
|
||||
<td>(Ultimate OR my) AND Repository – finds e.g. Ultimate Repository, my Repository, excludes e.g. Super Repository. Either "Ultimate" or “My” must exist, “Repository” must always exist.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|Definition|Example|
|
||||
|----------|-------|
|
||||
|() – terms inside parentheses are grouped together|"(Ultimate OR my) AND Repository" – finds e.g. \`Ultimate Repository\`, \`my Repository\`, excludes e.g. \`Super Repository\`. Either "Ultimate" or “My” must exist, “Repository” must always exist|
|
||||
|
||||
## Phrases
|
||||
|
||||
## Escaping Special Characters
|
||||
A phrase is a group of terms in a certain order. If you want to search for certain phrases then you can use the \`"\` operator.
|
||||
|
||||
The search supports escaping special characters that are part of the query syntax. The current list special characters are
|
||||
|Definition|Example|
|
||||
|----------|-------|
|
||||
|"" - terms inside the quotes are searched for as a phrase|"Ultimate Repository" – finds \`Ultimate Repository\` but not \`Repository Ultimate\`, \`Ultimate\` or \`Repository\`|
|
||||
|
||||
+ − && || ! ( ) { } [ ] ^ " ~ * ? : \ /
|
||||
|
||||
To escape these characters use the "\" before the character. For example to search for (1+1):2 use the query:
|
||||
|
||||
\(1\+1\)\:2
|
||||
|
||||
Source: [https://javadoc.io/static/org.apache.lucene/lucene-queryparser/8.9.0/org/apache/lucene/queryparser/classic/package-summary.html#package.description](https://javadoc.io/static/org.apache.lucene/lucene-queryparser/8.9.0/org/apache/lucene/queryparser/classic/package-summary.html#package.description)`;
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user