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

Was this helpful?

Get the documents of a search result

Code Example

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

Code Example

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 * {
27 * "_id": "aqmg7",
28 * "url": "/about",
29 * "documentType" "Site/Pages",
30 * "image": "wix:image://v1/45...bba2~mv2.jpg#originWidth=750&originHeight=750",
31 * "title": "Page title",
32 * "description": "Page text"
33 * },
34 * {
35 * "_id": "mzwrn",
36 * "url": "/shop",
37 * "documentType" "Site/Pages",
38 * "image": "wix:image://v1/20...8hui~mv2.jpg#originWidth=250&originHeight=250",
39 * "title": "Shop | My Site Name",
40 * "description": "My first product description"
41 * },
42 * {
43 * "_id": "k4ytu",
44 * "url": "/book-online",
45 * "documentType" "Site/Pages",
46 * "image": "wix:image://v1/11..._s_2.jpg#originWidth=3534&originHeight=2366",
47 * "title": "Book Online | My Site Name",
48 * "description": "My first service description"
49 * },
50 * ...
51 * ]
52 */
Perform a search on blog posts and get the documents of the search result

Code Example

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 * {
28 * "_id": "5df745e85db76a0017862a59",
29 * "url": "/post/manage-your-blog-from-your-live-site",
30 * "documentType" "Blog/Posts",
31 * "image": "wix:image://v1/20...8hui~mv2.jpg#originWidth=250&originHeight=250",
32 * "title": "Now You Can Blog from Everywhere!",
33 * "description": "We’ve made it quick and convenient for you to..."
34 * "hashtags": ["bloggingtips", "wixblog"]
35 * },
36 * {
37 * "_id": "5df745e85db76a0017862a61",
38 * "url": "/post/grow-your-blog-community",
39 * "documentType" "Blog/Posts",
40 * "image": "wix:image://v1/73...tg6i.jpg#originWidth=750&originHeight=750",
41 * "title": "Grow Your Blog Community",
42 * "description": "With Wix Blog, you’re not only sharing your voice...",
43 * "hashtags": ["bloggingtips", "wixblog", "yourvoice"]
44 * },
45 * {
46 * "_id": "5df745e85db76a0017862a64",
47 * "url": "/post/design-a-stunning-blog",
48 * "documentType" "Blog/Posts",
49 * "image": "wix:image://v1/11..._s_2.jpg#originWidth=3534&originHeight=2366",
50 * "title": "Design a Stunning Blog",
51 * "description": "When it comes to design, the Wix blog has..."
52 * "hashtags": "["wixblog", "stunning"]"
53 * }
54 * ]
55 */