Hi all, Just like Algolia provides robust support ...
# community-help
p
Hi all, Just like Algolia provides robust support for capturing user interactions through its Insights API, which accepts three types of events: click, conversion, and view events. These events enable features like NeuralSearch, Dynamic Re-Ranking, Query Categorization, Recommendation, and Personalization. By sending these events, you can enhance search relevance and user experience. Is there any option in '*Typesense'* that allows me to do all of this automatically without needing to implement custom solutions, like Algolia? Thanks!
f
Hey there. Algolia's Insights feature is called "Analytics Rules" in Typesense. Building models for recommendations / personalization can be done using Facebook's StarSpace for example, but it is involved. We have a guide for it here. It's not a completely custom solution, but the model building part happens outside of Typesense
p
I have tried this. Is there any other solution for this?
f
There's currently not a way to create this kind of recommendations that's fully automated. Developing a model to generate recommendations automatically is on the roadmap, but still early in development.
p
Okay, fine. My second question is, if I want to perform sorting on more than 3 fields, but the system doesn't allow it, how can I achieve it?
message has been deleted
f
You'd create an extra aggregator field and you'll set the weights for each extra field somewhere in your codebase. From then, you'll calculate an aggregated score, and sort on that. It has to be done outside of Typesense, and you will only pass an
int32
or
int64
value inside the document in Typesense
p
product_schema_obj = { 'name': collection_name, 'fields': [ { "name": "tag", "type": "int32","allow_empty": True,"facet": True }, { "name": "colorCount", "type": "int32","allow_empty": True,"facet": True }, { "name": "totalNoOfRating", "type": "int32","allow_empty": True,"facet": True }, { "name": "createdTimestamp", "type": "int32","facet": True}, {"name": "id", "type": "string" }, {"name": "parentProductId", "type": "string","facet": True }, {"name": "productName", "type": "string", "facet": True}, {'name': 'colourName', 'type': 'string',"facet": True,"allow_empty": True}, {'name': 'size', 'type': 'string',"facet": True,"allow_empty": True}, {"name": "slug", "type": "string"}, {"name": "searchAbleAttributes", "type": "object[]","facet": True,"allow_empty": True}, { "name": "variantCount", "type": "int32","allow_empty": True}, { "name": "maxQuantity", "type": "int32","allow_empty": True }, { "name": "categoryList", "type": "object[]","facet": True, "fields": [ { "name": "categoryId", "type": "string",}, { "name": "categoryName", "type": "string","facet": True }, { "name": "slug", "type": "string" } ],"allow_empty": True }, { "name": "offers", "type": "object", "fields": [ { "name": "offerId", "type": "string" }, { "name": "offerFor", "type": "int32" }, { "name": "offerName", "type": "object", "fields": [ { "name": "en", "type": "string" }, { "name": "fr", "type": "string" }, { "name": "hi", "type": "string" } ] }, { "name": "discountType", "type": "int32" }, { "name": "discountValue", "type": "float" }, { "name": "status", "type": "int32" ,"facet": True} ],"allow_empty": True }, { "name": "finalPriceList", "type": "object","facet": True, "fields": [ { "name": "basePrice", "type": "float","facet": True}, { "name": "finalPrice", "type": "float","facet": True}, { "name": "discountPrice", "type": "float","facet": True}, { "name": "discountPercentage", "type": "float","facet": True }, { "name": "discountType", "type": "int32"}, { "name": "taxRate", "type": "float" }, ] }, {"name": "availableQuantity", "type": "int32"}, {"name": "currency", "type": "string", "facet": True}, {"name": "currencySymbol", "type": "string", "facet": True}, {"name": "brandTitle", "type": "string", "facet": True,"allow_empty": True}, {"name": "images", "type": "object[]"}, {"name": "popularScore", "type": "float"}, {"name": "avgRating", "type": "float","facet": True}, {"name": "totalReview", "type": "int32","facet": True}, {"name": "inStock", "type": "bool", "facet": True}, {"name": "storeId", "type": "string" }, {"name": "isAllVariantInStock", "type": "string" }, { "name": "finalPrice", "type": "string"}, {"name": "metaData", "type": "object[]","allow_empty": True,"facet": True}, # {'name': 'product_name_vector', 'type': 'float[]', 'num_dim': 384}, # {'name': 'detailDescription_vecto', 'type': 'float[]', 'num_dim': 384}, {"name": "rating_score", "type": "float","facet": True}, {"name": "sellerRevenue", "type": "float","facet": True}, {"name": "positive_percentage", "type": "float","facet": True}, { "name": "embedding", "type": "float[]", "embed": { "from": [ "productName", "colourName", "brandTitle", "finalPrice" ], "model_config": { "model_name": "ts/all-MiniLM-L12-v2", } } } ], 'default_sorting_field': 'popularScore', "enable_nested_fields": True } return product_schema_obj This is my schema. Can you guide me on what needs to be done here?
f
When you want to sort by more than 3 fields in Typesense, you'll need to create what we call an "aggregate score" - basically a single number that combines all the factors you care about. Here's how it works: 1. First, decide which fields matter for sorting and how much each one matters. For example: ◦ Product popularity might be very important (25%) ◦ Ratings might be somewhat important (20%) ◦ Review count could be moderately important (15%) ◦ And so on... 2. For each product, calculate a combined score before you add it to Typesense: ◦ Take each field's value and normalize it (convert it to a value between 0 and 1) ◦ Multiply each normalized value by its importance percentage ◦ Add all these numbers together ◦ Multiply by a large number (like 1,000,000) to convert to an integer 3. Add a new field to your schema called something like "aggregateScore" as an int32 4. When you index your products, include this calculated score 5. Then you can sort by this single field in Typesense, and it will effectively be sorting by all your important fields at once, weighted according to how much you care about each one.
p
You explained it very well, and it will be useful for us. We will implement it soon, and if we face any problems, we will connect with you. Thank you, @Fanis Tharropoulos!
🙌 1