Skip to main content

Update Search Settings

Updates the search related settings of the project

HTTP Request

PATCH/api/settings/search

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with SearchSettingsPermission or Admin
  • Permission Code: 1047
  • Authentication: Token authentication

Request Body

FieldTypeRequiredDescription
core_product_searchable_fieldsArray[String]Noan array of strings defining which fields of the product are searchable in the panel
shop_product_searchable_fieldsArray[String]Noan array of strings defining which fields of the product are searchable in the shop
stop_words_listArray[String]Noan array of words that are ignored in the search results
ngram_min_limitIntegerNodefines the minimum tokenizing length of words used in elastic indexing
ngram_max_limitIntegerNodefines the maximum tokenizing length of words used in elastic indexing

Example Requests

1import requests
2
3# Update search settings
4response = requests.patch('http://www.example.com/api/settings/search', 
5  headers={'Authorization': 'Token <your_api_key>'},
6  json={
7    "shop_product_searchable_fields": ['title', 'title.ngram' ],
8    "core_product_searchable_fiels": ['title', 'title.ngram' ],
9    "stop_words_list": ['if', 'the', 'we' ],
10    "ngram_min_limit": 2,
11    "ngram_max_limit": 10
12  }
13)
14print(response.json())

Example Response

{
"core_product_searchable_fields": [
"title",
"title.ngram"
],
"shop_product_searchable_fields": [
"title",
"title.ngram"
],
"stop_words_list": [
"و",
"در",
"به",
],
"ngram_min_limit": 2,
"ngram_max_limit": 10
}

Notes

  • List of available fields to be used as product_searchable_fields are:
    • title
    • title.ngram
    • code
    • code.ngram
    • id
    • slug
    • excerpt
    • excerpt.ngram
  • The ngram postfix in the fields defines if we need ngram searching. Consider a word 'vitrin' is indexed in the elastic database. If ngram searching is also enabled, the search will also be done over vi, vit, vitr, vitri, vitrin tokens with typo tollerance and the results become more fuzzy.
  • stop_words_list are the words that are not indexed in the elastic database. For example we usually do not need to index the word 'که' in persian and also the searches over that word are useless. There is a default list of stop words which the user can modify.
  DEFAULT_STOP_WORDS_LIST = [
"و", "در", "به", "از", "که", "می", "این", "است", "را", "با", "های", "برای", "آن", "شود", "شده", "خود", "ها", "کرد",
"شد", "ای", "تا", "کند", "بر", "بود", "گفت", "نیز", "وی", "هم", "کنند", "دارد", "ما", "کرده", "یا", "اما", "باید",
"اند", "هر", "خواهد", "او", "مورد", "آنها", "باشد", "دیگر", "مردم", "نمی", "بین", "پیش", "پس", "اگر", "همه", "صورت",
"یکی", "هستند", "بی", "من", "دهد", "نیست", "استفاده", "داد", "داشته", "راه", "داشت", "چه", "همچنین", "کردند",
"داده", "بوده", "دارند", "همین", "سوی", "شوند", "بیشتر", "بسیار", "روی", "گرفته", "هایی", "تواند", "هیچ", "چند",
"بیش", "شدن", "کردن", "کنیم", "نشان", "حتی", "اینکه", "ولی", "توسط", "چنین", "برخی", "نه", "دیروز", "دوم", "درباره",
"بعد", "مختلف", "گیرد", "شما", "گفته", "آنان", "بار", "طور", "گرفته", "دهند", "گذاری", "بسیار", "طی", "بودند",
"کل", "تر", "براساس", "شدند", "ترین", "باشند", "ندارد", "چون", "قابل", "گوید", "دیگری", "همان", "خواهند", "قبل",
"آمده", "اکنون", "تحت", "طریق", "گیری", "جای", "هنوز", "چرا", "البته", "کنید", "سازی", "سوم", "کنیم", "بلکه", "زیر",
"توانند", "ضمن", "فقط", "بودن", "حق", "آید", "وقتی", "اش", "یابد", "نخستین", "مقابل", "خدمات", "امسال", "تاکنون",
"مانند", "آورد", "فکر", "آنچه", "نخست", "نشده", "شاید", "ساخته", "زیرا", "برداری", "کسی", "ریزی", "رفت", "گردد",
"مثل", "آمد", "ام", "دانست", "کمتر", "دادن", "تمامی", "جلوگیری", "بیشتری", "ایم", "ناشی", "چیزی", "آنکه",
"بنابراین", "ایشان", "بعضی", "دادند", "داشتند", "برخوردار", "نخواهد", "هنگام", "نباید", "غیر", "نبود", "دیده", "وگو",
"داریم", "چگونه", "بندی", "خواست", "فوق", "ده", "نویی", "هستیم", "دیگران", "همچنان", "ندارند", "روزهای", "آنجا",
"یکدیگر", "کردم", "بیست", "بروز", "سپس", "رفته", "آورده", "نمایید", "باشیم", "گویند", "خویش", "همواره", "گذشته",
"نداشته", "شناسی", "خواهیم", "آباد", "داشتن", "نظیر", "همچون", "باره", "نکرده", "شان", "دانند", "جایی", "بی", "جز",
"نزدِ", "نزدیکِ", "دنبالِ", "حدودِ", "مانندِ", "ضدِ", "هنگامِ", "برایِ", "مثلِ", "باره", "اثرِ", "تولِ", "علتِ", "قصدِ", "روب",
"جدا", "کی", "که", "چیست", "هست", "کجا", "کجاست", "کَی", "چطور", "کدام", "آیا", "مگر", "چندین", "یک", "چیزی", "دیگر",
"کسی", "بعری", "هیچ", "چیز", "جا", "کس", "هرگز", "یا", "تنها", "بلکه", "خیاه", "بله", "بلی", "آره", "آری", "مرسی",
"البته", "لطفاًً", "ها", "انکه", "وقتیکه", "همین", "پیش", "مدتی", "هنگامی", "مان", "تان"
]