|
1 | | - |
2 | | -<!-- Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> |
| 1 | +<!-- Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> |
3 | 2 |
|
4 | 3 | <picture> |
5 | 4 | <source media="(prefers-color-scheme: dark)" srcset="https://assets.vespa.ai/logos/Vespa-logo-green-RGB.svg"> |
|
9 | 8 |
|
10 | 9 | # Vespa sample applications - Lucene Linguistics |
11 | 10 |
|
12 | | -This app demonstrates using [Lucene Linguistics](https://docs.vespa.ai/en/lucene-linguistics.html). |
13 | | - |
| 11 | +This app demonstrates using [Lucene Linguistics](https://docs.vespa.ai/en/linguistics/lucene-linguistics.html). |
14 | 12 |
|
15 | 13 | <p data-test="run-macro init-deploy examples/lucene-linguistics/non-java"> |
16 | 14 | Requires at least Vespa 8.315.19 |
17 | 15 | </p> |
18 | 16 |
|
19 | | -## To try this application |
20 | | - |
21 | | -Follow [Vespa getting started](https://docs.vespa.ai/en/basics/deploy-an-application) |
| 17 | +Follow [app deploy guide](https://docs.vespa.ai/en/basics/deploy-an-application) |
22 | 18 | through the <code>vespa deploy</code> step, cloning `examples/lucene-linguistics/non-java` instead of `album-recommendation`. |
23 | 19 |
|
| 20 | + |
| 21 | +## Feed test data |
24 | 22 | Feed 3 sample documents in Norwegian, Swedish, and Finnish: |
25 | 23 |
|
26 | 24 | <pre data-test="exec"> |
27 | 25 | vespa feed ext/*.json |
28 | 26 | </pre> |
29 | 27 |
|
30 | | -Example queries: |
| 28 | + |
| 29 | +## Run queries |
31 | 30 |
|
32 | 31 | <pre data-test="exec" data-test-assert-contains="id:no:doc::1"> |
33 | | -vespa query 'yql=select * from doc where userQuery()'\ |
| 32 | +vespa query 'yql=select * from doc where userInput(@query)'\ |
34 | 33 | 'language=no' 'summary=debug-text-tokens' \ |
35 | 34 | 'query=tips til utendørsaktiviteter' |
36 | 35 | </pre> |
37 | 36 |
|
38 | 37 | <pre data-test="exec" data-test-assert-contains="id:sv:doc::1"> |
39 | | -vespa query 'yql=select * from doc where userQuery()'\ |
| 38 | +vespa query 'yql=select * from doc where userInput(@query)'\ |
40 | 39 | 'language=sv' 'summary=debug-text-tokens' \ |
41 | 40 | 'query=tips til utomhusaktiviteter' |
42 | 41 | </pre> |
43 | 42 |
|
44 | 43 | <pre data-test="exec" data-test-assert-contains="id:fi:doc::1"> |
45 | | -vespa query 'yql=select * from doc where userQuery()'\ |
| 44 | +vespa query 'yql=select * from doc where userInput(@query)'\ |
46 | 45 | 'language=fi' 'summary=debug-text-tokens' \ |
47 | 46 | 'query=vinkkejä ulkoilma-aktiviteetteihin' |
48 | 47 | </pre> |
49 | 48 |
|
50 | | -### Terminate container |
| 49 | +Using the [tokens](https://docs.vespa.ai/en/reference/schemas/schemas.html#tokens) feature, |
| 50 | +you can easily inspect the tokens generated by the linguistics processing |
| 51 | + |
| 52 | + |
| 53 | +### Use query tracing for insights |
| 54 | +Observe the query term linguistic processing in the trace output: |
| 55 | + |
| 56 | +<pre data-test="exec" data-test-assert-contains="id:no:doc::1"> |
| 57 | +vespa query 'yql=select * from doc where userInput(@query)'\ |
| 58 | + language=no summary=debug-text-tokens \ |
| 59 | + 'query=tips til utendørsaktiviteter' \ |
| 60 | + tracelevel=1 |
| 61 | +</pre> |
51 | 62 |
|
52 | | -Remove the container after use (Only relevant for local deployments) |
| 63 | + |
| 64 | +Increasing tracelevel is often useful: |
| 65 | + |
| 66 | +<pre data-test="exec" data-test-assert-contains="id:no:doc::1"> |
| 67 | +vespa query 'yql=select * from doc where ({grammar: "linguistics"}userInput(@query))'\ |
| 68 | + language=no summary=debug-text-tokens \ |
| 69 | + 'query=tips til utendørsaktiviteter' \ |
| 70 | + tracelevel=3 |
| 71 | +</pre> |
| 72 | + |
| 73 | +Above, you will find output like _"Stemming with language NORWEGIAN_BOKMAL using LuceneLinguistics"_ - |
| 74 | +This helps you validate that your application config is correct |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +## Cleanup |
| 79 | +For local deployments: Remove the container after use: |
53 | 80 | <pre data-test="exec"> |
54 | 81 | $ docker rm -f vespa |
55 | 82 | </pre> |
56 | | - |
|
0 commit comments