Finding relevant products using multiple keywords - amazon-product-api

I am trying to use the Amazon Product Advertising API to find relevant products.
I am searching using multiple keywords and am hoping to receive relevant results based on those keywords. The keywords can be random and at times not related at all to each other, so I want to find results that match the max number of keywords possible.
For example if I were to search using the keywords, 'Cat Figure Toys Kite Sim' I would hope to receive (at least) this result back, because it matches 3 of 5 keywords. At the moment for this search, no results are returned.
To make that search here is an example URL as displayed in the Scratchpad:
http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&Operation=ItemSearch&SubscriptionId=XXX&AssociateTag=XXX&SearchIndex=All&Keywords=Cat%20Figure%20Toys%20Kite%20Sim&ResponseGroup=Images,ItemAttributes,Offers
(Subscription ID and Associate Tag commented out).
Are the power search terms that I am not aware of that would make this request work?

Related

Select over multiple tables with different fields

Lets say I want to code a search engine for a website which has different tables (users, posts, articles, products), and create a generic search for all them.
Rather than how to do it I would like to know if it makes sense to do this in a single query, being a site with really low traffic.
Is there any pros am I missing besides any performance gain, or it would be the same if I run a query for each table?
This is very subjective question, and you will soon get some feedback to revise it as Stackoverflow is not a discussion area. Anyways,
My view is that join query or single query has no relevance here. A user can be join by post. But in search you want to list a user even if he has not written post. Also, the fields of User are different from product and different from post. So, why combine them, when their display is different?
Even if you want to fire a single query you can use union between queries, but imagine a front end. For user you probably want to show their avatar with name and public thing, for product again you will show their image and price, and for post you might go with google like result, all are in different grid/area of page.
Better option is you use ajax and search them separately and show them in separate boxes on your result page. like google ads or this site shows.

What is the best practice to write a search query for SOLR for an ecommerce website

It is my first project using SOLR, I have indexed the all products in solr and created a copyField named searchable. Copied field like product_title, description, categories titles, filters in this field.
I am using query given below to get results.
http://localhost:8080/solr/testcore/select?indent=on&q=status:1 AND is_single:0 AND searchable:sleeve+medium AND seller_status:1&wt=json
I am getting the matching results but couple of questions I have:
Is there any mechanism to sort result by exact match on top
I indexed the quantity and stock status of product, Can I give low weightage to products which have quantity = 0 or stock_status = 'Out of Stock" so out of stock items always display in bottom of search.
Thank you.
You can find the answer to your first question here.
About the second question, using eDismax you can use the boost query (bq) value:
bq=stock_status:"Out of Stock"^-0.1
in general though is better to boost important documents than de-boost docs with low importance.

Prevent duplicate rows with different queries

Let's say I have a products grid. In this grid there's a product called "Scarf XY".
Now a user wants to search for all items with similar name, so she types in a live-search box the word "Scarf X", and it will be performed an async request to retrieve from DB all rows that match that word.
I would like to prevent the new query to return again the row for "Scarf XY".
Is there a way to, let's say, "keep track" of already returned rows even from different queries?
(Sorry for my english)
Forgot to mention: every item returned from the DB is preserved in a local Array, that's why every new query may cause duplicate entries.
There is a way to do this with MySQL subqueries, but if this is meant for a site, this will be inefficient. For example, a user may type in search terms and then delete them. Such a system you described would result in eight SQL queries for a search of "Scarf XY", which will put an unnecessary load on your database server.
A more modern and resource efficient way of doing this would be to supply the browser a JSON array and use something like Typeahead.js from Twitter to display the information in a search bar client-side.

Advanced search in concatenating string

i am creating a search functionality for a website where i need to take the user's full address from an input e.g "Address 32, City,Region,Country, Postal Code"(no necessary with this order) and return the available restaurant that are around the area.
I have a table "address" where there is a field for each of the above elements.
I was thinking of concatenating the users address from the database and compare it with the user's input by help of SQL REGEXP.
Is there any other approximate SQL search that can give me that or can you suggest me a different approach?
A friend suggested using (http://www.simonemms.com/2011/02/08/codeigniter-solr/) however with a small research on it the problem still remains.
Trouble with concatentating the address together in SQL is you will miss out on it using indexes. Hence it will be slow. Added to which if you do not know the order of the input elements the chances of it matching what is concatenated from the database (is a likely different order) is slim.
I would suggest for much of the address items, split them off into different tables (ie a table of regions, another of countries, etc) and just store the ids in the columns in the users table.
For a search, identify which of the search fields go with which actual field then join on those to find the real address.
Also means you can identify typos more easily.

Thinking sphinx/mysql for non text search

Where I have a search which has a category (foreign key) and optional text, should I use thinking sphinx to "search" where a search string has not been submitted, solely the category?
It really depends on your use case. Let's say for example you have blog posts, and they have categories a, b, and c.
If you want yoursite.com/a/ to list all posts in category a in order from newest to oldest, then it's probably not the greatest idea to use sphinx/search for that. It will be a simple database query, possibly with pagination.
However, let's say you want that page to list all posts with that category, or that might relate to that category according to the text, and also maybe posts that have tags related to that category. In this case, it is probably best to use a search engine, like sphinx, to power this page. The search engine will be much faster if the equivalent database query is very expensive.