Skip to content

Commit 5e470af

Browse files
committed
HSEARCH-5070 Change macro to correctly display formulas in HTML docs
1 parent 5fbd3ea commit 5e470af

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

documentation/src/main/asciidoc/public/reference/_mapping-directfieldmapping.adoc

+26-8
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,19 @@ Only available on `@VectorField`.
385385
|===============
386386
|Value|Definition
387387
|`VectorSimilarity.L2`|An L2 (Euclidean) norm, that is a sensible default for most scenarios.
388-
Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \sqrt{\sum_{i=1}^{n} (x_i - y_i)^2 } ]
389-
and the score function is latexmath:[s = \frac{1}{1+d*d}]
388+
Distance between vectors `x` and `y` is calculated as
389+
ifdef::backend-html5[stem:[d(x,y) = \sqrt{\sum_{i=1}^{n} (x_i - y_i)^2 } ]]
390+
ifdef::backend-pdf[`d(x,y) = sqrt(sum[i=1; i<n+1]( (x(i) - y(i))*(x(i) - y(i)) )`]
391+
and the score function is
392+
ifdef::backend-html5[stem:[s = \frac{1}{1+d^2}]]
393+
ifdef::backend-pdf[`s = 1/(1+d*d)`]
390394
|`VectorSimilarity.DOT_PRODUCT`|Inner product (dot product in particular).
391-
Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]
392-
and the score function is latexmath:[s = \frac{1}{1+d}]
395+
Distance between vectors `x` and `y` is calculated as
396+
ifdef::backend-html5[stem:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]]
397+
ifdef::backend-pdf[`d(x,y) = sum[i=1; i< n+1] ( x(i)*y(i) ) `]
398+
and the score function is
399+
ifdef::backend-html5[stem:[s = \frac{1}{1+d}]]
400+
ifdef::backend-pdf[`s = 1/(1+d)`]
393401

394402
[WARNING]
395403
====
@@ -400,14 +408,24 @@ while byte vectors should simply all have the same norm.
400408
====
401409

402410
|`VectorSimilarity.COSINE`|Cosine similarity.
403-
Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \frac{1 - \sum_{i=1} ^{n} x_i \cdot y_i }{ \sqrt{ \sum_{i=1} ^{n} x_i^2 } \sqrt{ \sum_{i=1} ^{n} y_i^2 }} ]
404-
and the score function is latexmath:[s = \frac{1}{1+d}]
411+
Distance between vectors `x` and `y` is calculated as
412+
ifdef::backend-html5[stem:[d(x,y) = \frac{1 - \sum_{i=1} ^{n} x_i \cdot y_i }{ \sqrt{ \sum_{i=1} ^{n} x_i^2 } \sqrt{ \sum_{i=1} ^{n} y_i^2 }} ]]
413+
ifdef::backend-pdf[`d(x,y) = (1 - sum[i=1; i<n+1] ( x(i)*y(i) )/( sqrt( sum[i=1; i<n+1] x(i)*x(i) ) sqrt( sum[i=1; i<n+1] y(i)*y(i) ) ) )`]
414+
and the score function is
415+
ifdef::backend-html5[stem:[s = \frac{1}{1+d}]]
416+
ifdef::backend-pdf[`s = 1/(1+d)`]
405417
|`VectorSimilarity.MAX_INNER_PRODUCT`|Similar to a dot product similarity, but does not require vector normalization.
406-
Distance between vectors `x` and `y` is calculated as latexmath:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]
407-
and the score function is latexmath:[s = \begin{cases}
418+
Distance between vectors `x` and `y` is calculated as
419+
ifdef::backend-html5[stem:[d(x,y) = \sum_{i=1}^{n} x_i \cdot y_i ]]
420+
ifdef::backend-pdf[`d(x,y) = sum[i=1; i<n+1] ( x(i)*y(i) )`]
421+
and the score function is
422+
ifdef::backend-html5[]
423+
stem:[s = \begin{cases}
408424
\frac{1}{1-d} & \text{if d < 0}\\
409425
d+1 & \text{otherwise}
410426
\end{cases} ]
427+
endif::[]
428+
ifdef::backend-pdf[`d<0 ? 1/(1-d) : d+1`]
411429
|`VectorSimilarity.DEFAULT`|Use the backend-specific default. For the <<backend-lucene, Lucene backend>> an `L2` similarity is used.
412430
|===============
413431
+

documentation/src/main/asciidoc/public/reference/index.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:docinfodir: {docinfodir}
99
:docinfo: shared,private
1010
:title-logo-image: image:hibernate_logo_a.png[align=left,pdfwidth=33%]
11+
:stem: latexmath
1112

1213
:relfileprefix: ../../
1314
:relfilesuffix: /../en-US/html_single/index.html

0 commit comments

Comments
 (0)