Search.../

documents

Returns the documents that match the search.

Description

The current page of documents retrieved by the search.

The properties included in the search result documents array depend on the documentType specified for the search. If the documentType is set to Site/Pages, only the default document properties listed below are returned.

If the documentType is set to a specific Wix app collection (such as "Stores/Products"), the returned search result documents contain additional fields. The fields included in the returned documents are different for each documentType. To view the search schema for each document type, see the following articles:

The search result page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

When no documents match the search, the documents array is empty.

Type:

Array<Document>Read Only
NAME
TYPE
DESCRIPTION
_id
string

Unique document identifier.

image
string

Document image in the following format: wix:image://v1/<uri>/<filename>#originWidth=<width>&originHeight=<height>[&watermark=<watermark_manifest_string>]

documentType
string

Document type. One of the following:

  • Site/Pages
  • Blog/Posts
  • Bookings/Services
  • Forum/Content
  • Stores/Products
url
string

The relative page URL. For regular site pages, the URL defined in SEO settings. Note that the url for the home page is an empty string. For Wix app pages, the URL stored in the database collection.

description
string

For regular site pages, all text on the page. For Wix app pages, the description or content stored in the database collection.

title
string

For regular site pages, the SEO page title. For Wix app pages, the title or name stored in the database collection.

Was this helpful?

Get the documents of a search result

Copy Code
1let documents = results.documents;
2
3/**
4 * [
5 * {
6 * "_id": "msr9v",
7 * "url": "/about",
8 * "documentType" "Site/Pages",
9 * "image": "wix:image://v1/45...bba2~mv2.jpg#originWidth=750&originHeight=750",
10 * "title": "The Leader in Website Creation",
11 * "description": "Create your own professional web presence—exactly the way you want. Our powerful..."
12 * },
13 * ...
14 * ]
15 */
Perform a search and get the documents of the result

Copy Code
1import wixSearch from 'wix-search';
2
3// ...
4
5$w("#searchInput").onKeyPress((keyPress) => {
6 if (keyPress.key === "Enter") {
7 const phrase = $w("#searchInput").value;
8 wixSearch.search(phrase)
9 .find()
10 .then((results) => {
11 if (results.documents.length > 0) {
12 let documents = results.documents;
13 } else {
14 console.log("No matching results");
15 }
16 })
17 .catch((error) => {
18 console.log(error);
19 });
20 }
21});
22
23/**
24 * [
25 * {
26 * "_id": "aqmg7",
27 * "url": "/about",
28 * "documentType" "Site/Pages",
29 * "image": "wix:image://v1/45...bba2~mv2.jpg#originWidth=750&originHeight=750",
30 * "title": "Page title",
31 * "description": "Page text"
32 * },
33 * {
34 * "_id": "mzwrn",
35 * "url": "/shop",
36 * "documentType" "Site/Pages",
37 * "image": "wix:image://v1/20...8hui~mv2.jpg#originWidth=250&originHeight=250",
38 * "title": "Shop | My Site Name",
39 * "description": "My first product description"
40 * },
41 * {
42 * "_id": "k4ytu",
43 * "url": "/book-online",
44 * "documentType" "Site/Pages",
45 * "image": "wix:image://v1/11..._s_2.jpg#originWidth=3534&originHeight=2366",
46 * "title": "Book Online | My Site Name",
47 * "description": "My first service description"
48 * },
49 * ...
50 * ]
51 */
Perform a search on blog posts and get the documents of the search result

Copy Code
1import wixSearch from 'wix-search';
2
3// ...
4
5$w("#searchInput").onKeyPress((keyPress) => {
6 if (keyPress.key === "Enter") {
7 const phrase = $w("#searchInput").value;
8 wixSearch.search(phrase)
9 .documentType("Blog/Posts")
10 .find()
11 .then((results) => {
12 if (results.documents.length > 0) {
13 let documents = results.documents;
14 } else {
15 console.log("No matching results");
16 }
17 })
18 .catch((error) => {
19 console.log(error);
20 });
21 }
22});
23
24/**
25 * [
26 * {
27 * "_id": "5df745e85db76a0017862a59",
28 * "url": "/post/manage-your-blog-from-your-live-site",
29 * "documentType" "Blog/Posts",
30 * "image": "wix:image://v1/20...8hui~mv2.jpg#originWidth=250&originHeight=250",
31 * "title": "Now You Can Blog from Everywhere!",
32 * "description": "We’ve made it quick and convenient for you to..."
33 * "hashtags": ["bloggingtips", "wixblog"]
34 * },
35 * {
36 * "_id": "5df745e85db76a0017862a61",
37 * "url": "/post/grow-your-blog-community",
38 * "documentType" "Blog/Posts",
39 * "image": "wix:image://v1/73...tg6i.jpg#originWidth=750&originHeight=750",
40 * "title": "Grow Your Blog Community",
41 * "description": "With Wix Blog, you’re not only sharing your voice...",
42 * "hashtags": ["bloggingtips", "wixblog", "yourvoice"]
43 * },
44 * {
45 * "_id": "5df745e85db76a0017862a64",
46 * "url": "/post/design-a-stunning-blog",
47 * "documentType" "Blog/Posts",
48 * "image": "wix:image://v1/11..._s_2.jpg#originWidth=3534&originHeight=2366",
49 * "title": "Design a Stunning Blog",
50 * "description": "When it comes to design, the Wix blog has..."
51 * "hashtags": "["wixblog", "stunning"]"
52 * }
53 * ]
54 */