Lewati ke konten utama

getPagesByVectorSearch

Pencarian semantik (vektor) untuk halaman.

Deskripsi

Metode ini melakukan pencarian semantik (vektor) untuk halaman dari kueri bahasa alami - mencocokkan berdasarkan makna daripada kata kunci yang tepat. Ini mengembalikan sebuah Promise yang menyelesaikan menjadi objek IPagesResponse - sebuah wadah dengan items (halaman) dan total - bukan array kosong.

Halaman.getPagesByVectorSearch(

body*, langCode, offset, limit

);

Skema parameter

Skema

body(required): IPagesVectorSearch
Isi pencarian vektor
contoh:

{ queryText: "winter sale" }

body.queryText(required): string
Kuery pencarian dalam bahasa alami.
contoh: "diskon musim dingin"

body.vectorDistanceThreshold: number
Override ambang jarak kosinus (0..2).
contoh: 0.3

body.maxHits: number
Kandidat Top-K yang diambil sebelum paginasi. Default: 100. Max: 500.
contoh: 10

body.debug: boolean
Ketika true, setiap item yang dikembalikan mendapatkan field distance.
contoh: false

langCode: string
Kode bahasa. Default: "en_US"
contoh: "en_US"

offset: number
Parameter untuk paginasi. Default: 0
contoh: 0

limit: number
Parameter untuk paginasi. Default: 30
contoh: 30

Contoh

Contoh minimal

const response = await Pages.getPagesByVectorSearch({ queryText: 'winter sale' });

Contoh dengan atribut

const response = await Pages.getPagesByVectorSearch(
{
queryText: 'winter sale',
vectorDistanceThreshold: 0.3,
maxHits: 50,
debug: true,
},
'en_US',
0,
30,
);

Contoh respons

{
"items": [
{
"id": 9,
"config": {},
"depth": 1,
"parentId": 8,
"pageUrl": "blog1",
"attributeSetIdentifier": null,
"localizeInfos": {
"title": "Blog 1",
"htmlContent": "",
"plainContent": "",
"menuTitle": "Blog 1"
},
"isVisible": true,
"products": 0,
"childrenCount": 0,
"type": "common_page",
"position": 1,
"templateIdentifier": null,
"isSync": false,
"categoryPath": "blog/blog1",
"rating": {},
"attributeValues": {},
"moduleFormConfigs": []
}
],
"total": 1
}

Skema respons

Skema: IPagesResponse

items: IPagesEntity[]
Array objek halaman yang ditemukan.

items.id: number
Identifikasi objek.
contoh: 8

items.parentId: number | null
Id halaman induk, jika mengandung null, maka itu adalah halaman tingkat atas.
contoh: 10

items.pageUrl: string
Url halaman yang unik.
contoh: "blog"

items.depth: number
Kedalaman nesting halaman relatif terhadap parentId.
contoh: 10

items.localizeInfos: ILocalizeInfo
Nama halaman, dengan mempertimbangkan lokalisasi.
contoh:

{
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
}

items.isVisible: boolean
Tanda visibilitas halaman.
contoh: true

items.type: PageType
Tipe halaman.
contoh: "common_page"

items.templateIdentifier: string | null
Id pengguna dari template yang terhubung.
contoh: "template"

items.attributeSetIdentifier: string | null
Id set atribut.
contoh: "page"

items.attributeValues: IAttributeValues
Peta nilai atribut yang dikunci oleh penanda; objek kosong jika tidak ada.
contoh:

{
"text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": []
}
}

items.isSync: boolean
Indikasi pengindeksan halaman.
contoh: true

items.template: object
Objek template.
contoh:

{}

items.position: number
Nomor item (untuk pengurutan).
contoh: 2

items.config: Record<string, number>
Pengaturan output untuk halaman katalog.
contoh:

{
"rowsPerPage": 1,
"productsPerRow": 1
}

items.products: number
Jumlah produk yang terhubung ke halaman.
contoh: 0

items.childrenCount: number
Jumlah anak.
contoh: 1

items.blocks: IBlockEntity[] | string[]
blok.
contoh:

{
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 1
}

items.blocks.attributeValues: IAttributeValues
Peta nilai atribut yang dikunci oleh penanda; objek kosong jika tidak ada.
contoh:

{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
}
}

items.blocks.id: number
Identifikasi unik blok.
contoh: 1234

items.blocks.localizeInfos: ILocalizeInfo
Informasi lokalisasi untuk blok.
contoh:

{
"key": "value"
}

items.blocks.version: number
Versi entitas blok.
contoh: 1

items.blocks.identifier: string
Identifikasi string unik untuk blok.
contoh: "block1"

items.blocks.type: BlockType
Tipe blok.
contoh: "product"

items.blocks.position: number
Posisi blok untuk pengurutan.
contoh: 1

items.blocks.templateIdentifier: string | null
Identifikasi untuk template yang digunakan oleh blok, atau null jika tidak berlaku.
contoh: "template1"

items.blocks.isVisible: boolean
Menunjukkan apakah blok terlihat.
contoh: true

items.blocks.countElementsPerRow: number
Jumlah elemen yang ditampilkan per baris dalam blok, jika berlaku.
contoh: 3

items.blocks.quantity: number
Jumlah item dalam blok, jika berlaku.
contoh: 5

items.blocks.similarProducts: IProductsResponse
Respons yang berisi produk serupa yang terkait dengan blok.
contoh:

{
"total": 10,
"items": []
}

items.blocks.products: IProductsEntity[]
Array entitas produk yang terkait dengan blok.
contoh:

[
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]

items.moduleFormConfigs: Array<IFormConfig>
Konfigurasi formulir modul yang terhubung ke halaman.

items.rating: IRating
Data penilaian.

items.total: string
Jumlah total produk yang terhubung ke halaman.
contoh: "10"

items.categoryPath: string | null
String jalur kategori; null untuk halaman bersarang yang tidak memiliki jalur kategori sendiri.
contoh: "katalog"
items.distance: number
Jarak kosinus ke kueri. Hanya dikembalikan oleh endpoint pencarian semantik (vektor) ketika debug: true diteruskan dalam isi pencarian.
contoh: 0.12

total: number
Jumlah total catatan yang ditemukan.
contoh: 100

ℹ️ Pencarian semantik mencocokkan berdasarkan makna, bukan pada teks literal. Untuk pencocokan kata kunci di seluruh jenis entitas sekaligus gunakan globalSearch().