Solr Schema advice in multitenant ecommerce site - solr

I have a multitenant site, whose products are indexed in Solr, so visitors can search by product name, or any other product property.
Now, I would like to filter by product price.
There are two problems:
Not all tentants have the same products on their website.
The product price can differ from one customer to another, as each tenant can change the price of each of the product it uses.
So given a tenantId, I'd like to search for all products that tenant has, which are in a given price range.
I don't think I can store a Map<CustomerId, Price> for each product and somehow query that, so I'm a bit stuck on how to design the schema. At the moment, I just have, for each product, a multivalued property called customer, so I can just filter by all products of a given tentant.
Any help appreciated, thanks!

Related

What is the best practice for storing shopping basket in Firestore?

I'm creating a flutter app which needs shopping basket functionality. I'm using Firestore to save the contents of user's shopping baskets but do not know how best to do this.
At the moment, I have a collection called 'baskets' which contains documents (with the users id as the reference).
Within these documents, should I have a field which is a dictionary/map with key = productID and value = quantity, or should I just create a field for every product that the user adds to their basket?
Or is there a better way altogether (still using Firestore).
You are on the right track. Creating a root collection called baskets, under which each user has its own document based on the user's unique UID is good. Now, inside each of the user's documents, you can add a sub-collection called cartItems, where you will hold a document per product.
For each product then you can add its name, price, and amount and other descriptive product fields. That way instead of having multiple documents of the same product, just add a document per product, and a field called amount which you increment as users add more items of that same product.
You will be able to calculate how much is the total cost of their cart by pulling all documents, adding up all the amount fields of products times their individual prices, etc.
You can increment / decrement the amount of products, or altogether remove the product from their basket by removing the product document.
The main collection baskets should look like this:
While your cartItems subcollection could look like this:
Good luck!

In a Postgresql database where a seller has many products and products have many sellers, where should price(s) get stored?

Using django and python, I am building a web app that tracks prices. The user is a manufacturer and will want reports. Each of their products has a recommended price. Each product could have more than one seller, and each seller could have more than one product. My question is, where do I store the prices, especially the seller's price? Right now I have my database schema so the product table stores the recommended price and the seller's price, and that means one single product is repeated a lot of times. Is there a better way to do this?
Per the recommendations below this is the correct db schema:
Since you have a case of many-to-many then your structure would use a link table. You’ll have tables seller, product and link_seller_product. The last table has a link to the seller table via id as well as the product table via id. This table therefore can also have any information that is dependent on the seller and the product and is not fixed for either. So price-per-product-per-seller goes there.
So add the additional link table with columns sellerid, productid and price and you’ll have only single rows in sellers and products but each seller can have their own price for the product.
You're not adequately representing the one-to-many relationship between products and sellers. Your product table has the seller_id and the seller_price, but if one product is sold by many sellers, it cannot.
Instead of duplicating product entries so the same product can have multiple sellers, what you need is a table between products and sellers.
CREATE TABLE seller_products (
seller_id integer,
product_id integer,
price decimal
);
I'll leave the indexes foreign keys etc to you. Seller ID and product ID might be a unique combination ( historical data is best removed from active datasets for performance longevity ) , but of course any given product will be listed once for each seller that sells it and any given seller will be listed once per product it sells ( along with its unique price).
Then you can join the table back to products to get the data you currently store denormalized in the products table directly :
SELECT *
FROM products
LEFT JOIN seller_products ON ( seller_products.product_id = products.id)
This is a Data Warehouse question.
I would recommend putting prices on a Fact as measures and having only attributes on the Dimensions.
Dimensions:
Product
Seller
Manufacturer
Fact (Columns):
List item
Seller Price
List item
MRSP
Product ID
Seller ID
Manufacturer ID
Timestamp

Google appengine search api sort by ndb value

I am having a list of products. I have added to the google appengine search API index with each product being each document. User can search for products. So far everything is good.
Now I want the user to be able to sort by price of the product ascending or descending. If i have fixed price for each product, I could simply build separate indexes and put the documents inside them. But unfortunately, the prices are dynamic. The product price can change 3-4 times a day. I have more than 200,000 products.
Since rewriting the document each time the price changes is bad, I have a ndb datastore model which has the documentID and price as the entity attributes.
Is there any way to sort the search api results, based on the price in the ndb model. Alternate design solutions are also welcome.

how to do grouping of analytics data?

I am working on a Unity3D augmented reality app (iOS and Android) where I want to send AR campaign data to Google Analytics.
Example of what I exactly want to do
Information about AR campaigns available,
Category (can be anything...automobile, entertainment or travel), campaign name (each campaign is related to only one of the categories), user gender and age (available from login details).
I want the grouping of data on Google Analytics by,
category - data of all the campaigns grouped by each category
gender in a given category - data of how many males / females scanned a particular campaign, category wise
age in a given category - data of user's age who scanned a particular campaign, category wise
gender regardless of the category - data of how many males / females scanned a particular campaign irrespective of category
age regardless of the category - data of user's age who scanned a particular campaign irrespective of category
So as to generate and export reports for each of the above mentioned group.
I sent a couple of screens and events to GA but not sure how to group data as per my requirements and generate reports. I couldn't find any documentation of tutorial that describes a similar use-case. I am using the latest plugin from Google Analytics.
Any help is much appreciated.
Thanks!

Solr customizing with Websphere Commerce

I have a strange requirement in Solr.
The business model is like for each store in state (say victoria), we have different sales catalog (like Richmond, Brunswick etc) which in turn act as fulfillment centers on their own.
so my url of storeId- vic and catalogId-Richmond will retrieve me catalogues with richmond's store.
Now the requirement is I need to filter out the products based on the inventory for each of these sales catalogues.
I constructed a TI table which has the following structure
catentry_id -------- QUANTITY_RICFUL-------------QUANTITY_BrunFUL
1234-------------------0------------------------------------20
I had incorporate the changes in solr query to add these columns in the final result too.
But I do not know how to filter out the products in the front end during catalogue navigation or during search.
Any help would be much appreciated!!!
So basically you want to tie the returned catalog entries in a list with inventory? For instance, when they click on a category you do not want to display products with no inventory?
This would be a customization you can either do at the Solr Level or at the JSP level. You should probably track inventory in commerce (import it) into a field Solr can key off of and then only return items with the flag set to greater than zero. I am not sure if you need actual inventory or just a boolean. Are you using a single fulfillment center or multiple ones? Multiple gets a bit trickier and it would require them to log in most likely but then fulfillment would be addressed by the ship to address.
If the store is set up with ATP inventory then you should just get this for free, as products not in stock will simply not be displayed. Check out this page in the infocenter - http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/index.jsp?topic=%2Fcom.ibm.commerce.user.doc%2Fconcepts%2Fcosatpatpandnonatp.htm
I am not sure what you are trying to ask here but it seems you are trying to display a Quantity dropdown or display an Quantity field under each product on a search page which to me makes no sense from a UI perspective. Also keep in mind if you have integrated with a 3rd party inventory model that runs every few mins/hours etc. How often do you plan to run indexing etc?
I would rather leave such complexity to a Prodcut Detail page. If you do require to show an Quantity field on the search page I would rather prefer displaying a QuickView popup/modal that displays the color/size attributes with the quantity dropdown etc and enable a user to add an item to his/her shopping cart.

Resources