Skip to content

Commit 2fa346d

Browse files
committed
adjust to 9.1
1 parent 05959f8 commit 2fa346d

File tree

6 files changed

+4
-103
lines changed

6 files changed

+4
-103
lines changed

docs/changelog/138140.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pr: 138140
2-
summary: "Fix semantic highlighting when using a `knn` query with minimum `similarity` and when using `bbq_disk`"
2+
summary: "Fix semantic highlighting when using a `knn` query with minimum `similarity`
33
area: Relevance
44
type: bug
55
issues: []

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/highlight/SemanticTextHighlighterTests.java

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272

7373
public class SemanticTextHighlighterTests extends MapperServiceTestCase {
7474
private static final String SEMANTIC_FIELD_E5 = "body-e5";
75-
private static final String SEMANTIC_FIELD_E5_DISK_BBQ = "body-e5-disk_bbq";
7675
private static final String SEMANTIC_FIELD_ELSER = "body-elser";
7776

7877
private final boolean useLegacyFormat;
@@ -213,7 +212,6 @@ public void testDenseVectorWithSimilarityThreshold() throws Exception {
213212
vector,
214213
10,
215214
10,
216-
10f,
217215
null,
218216
0.85f
219217
);
@@ -233,85 +231,6 @@ public void testDenseVectorWithSimilarityThreshold() throws Exception {
233231
);
234232
}
235233

236-
@SuppressWarnings("unchecked")
237-
public void testDenseVectorWithDiskBBQandSimilarityThreshold() throws Exception {
238-
var mapperService = createDefaultMapperService(useLegacyFormat);
239-
Map<String, Object> queryMap = (Map<String, Object>) queries.get("dense_vector_1");
240-
float[] vector = readDenseVector(queryMap.get("embeddings"));
241-
var fieldType = (SemanticTextFieldMapper.SemanticTextFieldType) mapperService.mappingLookup()
242-
.getFieldType(SEMANTIC_FIELD_E5_DISK_BBQ);
243-
244-
KnnVectorQueryBuilder knnQuery = new KnnVectorQueryBuilder(
245-
fieldType.getEmbeddingsField().fullPath(),
246-
vector,
247-
10,
248-
10,
249-
10f,
250-
null,
251-
0.85f
252-
);
253-
NestedQueryBuilder nestedQueryBuilder = new NestedQueryBuilder(fieldType.getChunksField().fullPath(), knnQuery, ScoreMode.Max);
254-
var shardRequest = createShardSearchRequest(nestedQueryBuilder);
255-
var sourceToParse = new SourceToParse("0", readSampleDoc(useLegacyFormat), XContentType.JSON);
256-
257-
String[] expectedPassages = ((List<String>) queryMap.get("expected_with_similarity_threshold")).toArray(String[]::new);
258-
assertHighlightOneDoc(
259-
mapperService,
260-
shardRequest,
261-
sourceToParse,
262-
SEMANTIC_FIELD_E5_DISK_BBQ,
263-
expectedPassages.length,
264-
HighlightBuilder.Order.SCORE,
265-
expectedPassages
266-
);
267-
}
268-
269-
@SuppressWarnings("unchecked")
270-
public void testDenseVectorWithDiskBBQ() throws Exception {
271-
var mapperService = createDefaultMapperService(useLegacyFormat);
272-
Map<String, Object> queryMap = (Map<String, Object>) queries.get("dense_vector_1");
273-
float[] vector = readDenseVector(queryMap.get("embeddings"));
274-
var fieldType = (SemanticTextFieldMapper.SemanticTextFieldType) mapperService.mappingLookup()
275-
.getFieldType(SEMANTIC_FIELD_E5_DISK_BBQ);
276-
277-
KnnVectorQueryBuilder knnQuery = new KnnVectorQueryBuilder(
278-
fieldType.getEmbeddingsField().fullPath(),
279-
vector,
280-
10,
281-
10,
282-
10f,
283-
null,
284-
null
285-
);
286-
NestedQueryBuilder nestedQueryBuilder = new NestedQueryBuilder(fieldType.getChunksField().fullPath(), knnQuery, ScoreMode.Max);
287-
var shardRequest = createShardSearchRequest(nestedQueryBuilder);
288-
var sourceToParse = new SourceToParse("0", readSampleDoc(useLegacyFormat), XContentType.JSON);
289-
290-
String[] expectedScorePassages = ((List<String>) queryMap.get("expected_by_score")).toArray(String[]::new);
291-
for (int i = 0; i < expectedScorePassages.length; i++) {
292-
assertHighlightOneDoc(
293-
mapperService,
294-
shardRequest,
295-
sourceToParse,
296-
SEMANTIC_FIELD_E5_DISK_BBQ,
297-
i + 1,
298-
HighlightBuilder.Order.SCORE,
299-
Arrays.copyOfRange(expectedScorePassages, 0, i + 1)
300-
);
301-
}
302-
303-
String[] expectedOffsetPassages = ((List<String>) queryMap.get("expected_by_offset")).toArray(String[]::new);
304-
assertHighlightOneDoc(
305-
mapperService,
306-
shardRequest,
307-
sourceToParse,
308-
SEMANTIC_FIELD_E5_DISK_BBQ,
309-
expectedOffsetPassages.length,
310-
HighlightBuilder.Order.NONE,
311-
expectedOffsetPassages
312-
);
313-
}
314-
315234
private MapperService createDefaultMapperService(boolean useLegacyFormat) throws IOException {
316235
var mappings = Streams.readFully(SemanticTextHighlighterTests.class.getResourceAsStream("mappings.json"));
317236
var settings = Settings.builder()

x-pack/plugin/inference/src/test/resources/org/elasticsearch/xpack/inference/highlight/mappings.json

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"properties": {
44
"body": {
55
"type": "text",
6-
"copy_to": ["body-elser", "body-e5", "body-e5-disk_bbq"]
6+
"copy_to": ["body-elser", "body-e5"]
77
},
88
"body-e5": {
99
"type": "semantic_text",
@@ -15,21 +15,6 @@
1515
"element_type": "float"
1616
}
1717
},
18-
"body-e5-disk_bbq": {
19-
"type": "semantic_text",
20-
"inference_id": ".multilingual-e5-small-elasticsearch",
21-
"model_settings": {
22-
"task_type": "text_embedding",
23-
"dimensions": 384,
24-
"similarity": "cosine",
25-
"element_type": "float"
26-
},
27-
"index_options": {
28-
"dense_vector": {
29-
"type": "bbq_disk"
30-
}
31-
}
32-
},
3318
"body-elser": {
3419
"type": "semantic_text",
3520
"inference_id": ".elser-2-elasticsearch",
@@ -39,4 +24,4 @@
3924
}
4025
}
4126
}
42-
}
27+
}

x-pack/plugin/inference/src/test/resources/org/elasticsearch/xpack/inference/highlight/queries.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,6 @@
399399
"After the marshland between the river Seine and its slower 'dead arm' to its north was filled in from around the 10th century, Paris's cultural centre began to move to the Right Bank. In 1137, a new city marketplace (today's Les Halles) replaced the two smaller ones on the Île de la Cité and Place de Grève (Place de l'Hôtel de Ville). The latter location housed the headquarters of Paris's river trade corporation, an organisation that later became, unofficially (although formally in later years), Paris's first municipal government.\n\n\nIn the late 12th century, Philip Augustus extended the Louvre fortress to defend the city against river invasions from the west, gave the city its first walls between 1190 and 1215, rebuilt its bridges to either side of its central island, and paved its main thoroughfares. In 1190, he transformed Paris's former cathedral school into a student-teacher corporation that would become the University of Paris and would draw students from all of Europe.\n\n\nWith 200,000 inhabitants in 1328, Paris, then already the capital of France, was the most populous city of Europe. By comparison, London in 1300 had 80,000 inhabitants. By the early fourteenth century, so much filth had collected inside urban Europe that French and Italian cities were naming streets after human waste. In medieval Paris, several street names were inspired by merde, the French word for \"shit\".\n\n\n",
400400
"In March 2001, Bertrand Delanoë became the first socialist mayor. He was re-elected in March 2008. In 2007, in an effort to reduce car traffic, he introduced the Vélib', a system which rents bicycles. Bertrand Delanoë also transformed a section of the highway along the Left Bank of the Seine into an urban promenade and park, the Promenade des Berges de la Seine, which he inaugurated in June 2013.\n\n\nIn 2007, President Nicolas Sarkozy launched the Grand Paris project, to integrate Paris more closely with the towns in the region around it. After many modifications, the new area, named the Metropolis of Grand Paris, with a population of 6.7 million, was created on 1 January 2016. In 2011, the City of Paris and the national government approved the plans for the Grand Paris Express, totalling 205 km (127 mi) of automated metro lines to connect Paris, the innermost three departments around Paris, airports and high-speed rail (TGV) stations, at an estimated cost of €35 billion. The system is scheduled to be completed by 2030.\n\n\nIn January 2015, Al-Qaeda in the Arabian Peninsula claimed attacks across the Paris region. 1.5 million people marched in Paris in a show of solidarity against terrorism and in support of freedom of speech. In November of the same year, terrorist attacks, claimed by ISIL, killed 130 people and injured more than 350.\n\n\n",
401401
"Bal-musette is a style of French music and dance that first became popular in Paris in the 1870s and 1880s; by 1880 Paris had some 150 dance halls. Patrons danced the bourrée to the accompaniment of the cabrette (a bellows-blown bagpipe locally called a \"musette\") and often the vielle à roue (hurdy-gurdy) in the cafés and bars of the city. Parisian and Italian musicians who played the accordion adopted the style and established themselves in Auvergnat bars, and Paris became a major centre for jazz and still attracts jazz musicians from all around the world to its clubs and cafés.\n\n\nParis is the spiritual home of gypsy jazz in particular, and many of the Parisian jazzmen who developed in the first half of the 20th century began by playing Bal-musette in the city. Django Reinhardt rose to fame in Paris, having moved to the 18th arrondissement in a caravan as a young boy, and performed with violinist Stéphane Grappelli and their Quintette du Hot Club de France in the 1930s and 1940s.\n\n\nImmediately after the War the Saint-Germain-des-Pres quarter and the nearby Saint-Michel quarter became home to many small jazz clubs, including the Caveau des Lorientais, the Club Saint-Germain, the Rose Rouge, the Vieux-Colombier, and the most famous, Le Tabou. They introduced Parisians to the music of Claude Luter, Boris Vian, Sydney Bechet, Mezz Mezzrow, and Henri Salvador. "
402-
],
403-
"expected_with_similarity_threshold": [
404-
"\nParis (.mw-parser-output .IPA-label-small{font-size:85%}.mw-parser-output .references .IPA-label-small,.mw-parser-output .infobox .IPA-label-small,.mw-parser-output .navbox .IPA-label-small{font-size:100%}French pronunciation: ⓘ) is the capital and largest city of France. With an estimated population of 2,102,650 residents in January 2023 in an area of more than 105 km2 (41 sq mi), Paris is the fourth-largest city in the European Union and the 30th most densely populated city in the world in 2022. Since the 17th century, Paris has been one of the world's major centres of finance, diplomacy, commerce, culture, fashion, and gastronomy. Because of its leading role in the arts and sciences and its early adaptation of extensive street lighting, it became known as the City of Light in the 19th century.\n\n\nThe City of Paris is the centre of the Île-de-France region, or Paris Region, with an official estimated population of 12,271,794 inhabitants in January 2023, or about 19% of the population of France. The Paris Region had a nominal GDP of €765 billion (US$1.064 trillion when adjusted for PPP) in 2021, the highest in the European Union. According to the Economist Intelligence Unit Worldwide Cost of Living Survey, in 2022, Paris was the city with the ninth-highest cost of living in the world.\n\n\n"
405402
]
406403
},
407404
"sparse_vector_1": {
@@ -467,4 +464,4 @@
467464
"Diderot and D'Alembert published their Encyclopédie in 1751, before the Montgolfier Brothers launched the first manned flight in a hot air balloon on 21 November 1783. Paris was the financial capital of continental Europe, as well the primary European centre for book publishing, fashion and the manufacture of fine furniture and luxury goods. On 22 October 1797, Paris was also the site of the first parachute jump in history, by Garnerin.\n\n\nIn the summer of 1789, Paris became the centre stage of the French Revolution. On 14 July, a mob seized the arsenal at the Invalides, acquiring thousands of guns, with which it stormed the Bastille, a principal symbol of royal authority. The first independent Paris Commune, or city council, met in the Hôtel de Ville and elected a Mayor, the astronomer Jean Sylvain Bailly, on 15 July.\n\n\nLouis XVI and the royal family were brought to Paris and incarcerated in the Tuileries Palace. In 1793, as the revolution turned increasingly radical, the king, queen and mayor were beheaded by guillotine in the Reign of Terror, along with more than 16,000 others throughout France. The property of the aristocracy and the church was nationalised, and the city's churches were closed, sold or demolished. A succession of revolutionary factions ruled Paris until 9 November 1799 (coup d'état du 18 brumaire), when Napoleon Bonaparte seized power as First Consul.\n\n\n"
468465
]
469466
}
470-
}
467+
}

0 commit comments

Comments
 (0)