container-search/src/main/resources/queryExamples.md
This is a resource file containing example queries for the MCP client to help the client understand how to query a Vespa application. The example queries demonstrate how to transform Command-line queries into the format required by the MCP client.:
Note: The examples are based on the Vespa application and schemas used in the news tutorial. Most likely the Vespa application will be different so the example queries is meant for demonstration purposes only for the MCP client. The MCP client would need to adapt the queries to the specific application and schemas it is working with. For other queries, consult Vespa's query language documentation.
The examples are based on the news tutorial application with the following schemas:
schema news {
document news {
field news_id type string {
indexing: summary | attribute
attribute: fast-search
}
field category type string {
indexing: summary | attribute
}
field subcategory type string {
indexing: summary | attribute
}
field title type string {
indexing: index | summary
index: enable-bm25
}
field abstract type string {
indexing: index | summary
index: enable-bm25
}
field body type string {
indexing: index | summary
index: enable-bm25
}
field url type string {
indexing: index | summary
}
field date type int {
indexing: summary | attribute
attribute: fast-search
}
field clicks type int {
indexing: summary | attribute
}
field impressions type int {
indexing: summary | attribute
}
field embedding type tensor<float>(d0[50]) {
indexing: attribute | index
attribute {
distance-metric: dotproduct
}
}
}
fieldset default {
fields: title, abstract, body
}
rank-profile popularity inherits default {
function popularity() {
expression: if (attribute(impressions) > 0, attribute(clicks) / attribute(impressions), 0)
}
first-phase {
expression: nativeRank + 100 * popularity
}
}
rank-profile recommendation inherits default {
first-phase {
expression: closeness(field, embedding)
}
}
}
schema user {
document user {
field user_id type string {
indexing: summary | attribute
attribute: fast-search
}
field embedding type tensor<float>(d0[50]) {
indexing: summary | attribute
}
}
}
vespa query 'yql=select * from news where true' {
"yql": "select * from sources where true",
"parameters": {
"sources": "news"
}
}
vespa query 'yql=select * from news where abstract contains "election"' {
"yql": "select * from sources where abstract contains 'election'",
"parameters": {
"sources": "news"
}
}
vespa query 'yql=select * from news where default contains "music" and default contains "festival"' 'hits=2' {
"yql": "select * from sources where default contains 'music' and default contains 'festival'",
"parameters": {
"sources": "news",
"hits": 2
}
}
vespa query 'yql=select * from news where date <= 20191110 AND date >= 20191108' {
"yql": "select * from sources where date <= 20191110 AND date >= 20191108",
"parameters": {
"sources": "news"
}
}
vespa query 'yql=select date from news where default contains phrase("music","festival") order by date desc' {
"yql": "select * from sources where default contains phrase('music','festival') order by date desc",
"parameters": {
"sources": "news"
}
}
vespa query 'yql=select * from news where default contains "music"' 'ranking=popularity' {
"yql": "select * from sources where default contains 'music'",
"parameters": {
"sources": "news",
"ranking": "popularity"
}
}
vespa query 'yql=select embedding from user where user_id contains "U33527"' {
"yql": "select embedding from sources where user_id contains 'U33527'",
"parameters": {
"sources": "user"
}
}
vespa query 'yql=select * from sources news where {targetHits:3}nearestNeighbor(embedding, user_embedding)' 'hits=3' 'ranking.features.query(user_embedding)={<U33527 embedding>}' 'ranking.profile=recommendation' {
"yql": "select * from sources where {targetHits:3}nearestNeighbor(embedding, user_embedding)",
"parameters": {
"sources": "news",
"hits": 3,
"ranking.features.query(user_embedding)": "<U33527 embeddings as a list>",
"ranking": "recommendation"
}
}