You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/search/search-more-like-this.md
+30-8Lines changed: 30 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,28 +22,50 @@ ms.date: 11/04/2019
22
22
23
23
By default, the contents of all top-level searchable fields are considered. If you want to specify particular fields instead, you can use the `searchFields` parameter.
24
24
25
-
You cannot use moreLikeThis on searchable sub-fields in a [complex type](search-howto-complex-data-types.md).
25
+
You cannot use `MoreLikeThis` on searchable sub-fields in a [complex type](search-howto-complex-data-types.md).
26
26
27
-
## Examples
27
+
## Examples
28
28
29
-
Below is an example of a moreLikeThis query. The query finds documents whose description fields are most similar to the field of the source document as specified by the `moreLikeThis` parameter.
29
+
All following examples use the hotels sample from [Quickstart: Create a search index in the Azure portal](search-get-started-portal.md).
30
+
31
+
### Simple query
32
+
33
+
The following query finds documents whose description fields are most similar to the field of the source document as specified by the `moreLikeThis` parameter:
30
34
31
35
```
32
-
Get /indexes/hotels/docs?moreLikeThis=1002&searchFields=description&api-version=2019-05-06-Preview
36
+
GET /indexes/hotels-sample-index/docs?moreLikeThis=29&searchFields=Description&api-version=2019-05-06-Preview
33
37
```
34
38
39
+
In this example, the request searches for hotels similar to the one with `HotelId` 29.
40
+
Rather than using HTTP GET, you can also invoke `MoreLikeThis` using HTTP POST:
41
+
35
42
```
36
-
POST /indexes/hotels/docs/search?api-version=2019-05-06-Preview
43
+
POST /indexes/hotels-sample-index/docs/search?api-version=2019-05-06-Preview
37
44
{
38
-
"moreLikeThis": "1002",
39
-
"searchFields": "description"
45
+
"moreLikeThis": "29",
46
+
"searchFields": "Description"
40
47
}
41
48
```
42
49
50
+
### Apply filters
51
+
52
+
`MoreLikeThis` can be combined with other common query parameters like `$filter`. For instance, the query can be restricted to only hotels whose category is 'Budget' and where the rating is higher than 3.5:
53
+
54
+
```
55
+
GET /indexes/hotels-sample-index/docs?moreLikeThis=20&searchFields=Description&$filter=(Category eq 'Budget' and Rating gt 3.5)&api-version=2019-05-06-Preview
56
+
```
57
+
58
+
### Select fields and limit results
59
+
60
+
The `$top` selector can be used to limit how many results should be returned in a `MoreLikeThis` query. Also, fields can be selected with `$select`. Here the top three hotels are selected along with their ID, Name, and Rating:
61
+
62
+
```
63
+
GET /indexes/hotels-sample-index/docs?moreLikeThis=20&searchFields=Description&$filter=(Category eq 'Budget' and Rating gt 3.5)&$top=3&$select=HotelId,HotelName,Rating&api-version=2019-05-06-Preview
64
+
```
43
65
44
66
## Next steps
45
67
46
68
You can use any web testing tool to experiment with this feature. We recommend using Postman for this exercise.
47
69
48
70
> [!div class="nextstepaction"]
49
-
> [Explore Azure Cognitive Search REST APIs using Postman](search-get-started-postman.md)
71
+
> [Explore Azure Cognitive Search REST APIs using Postman](search-get-started-postman.md)
0 commit comments