Exemple #1
0
    def test_find_products(self):
        """Test that full-text search works on products.

           In addition to finding terms in a product's
           title or description, we want to test that
           postgres is stemming and lowercasing the queries.
        """

        # Check that postgres is dealing with case
        results1 = Product.find_products('headphones')

        self.assertEqual(len(results1), 1)
        self.assertEqual(results1[0][0], "A1")

        # Check that postgres is stemming
        results2 = Product.find_products('screens')

        self.assertEqual(len(results2), 1)
        self.assertEqual(results2[0][0], "A2")
Exemple #2
0
def search_products():
    """Retrieve data from search form and display product results page."""

    search_query = request.args.get('query')

    # Retrieve products from db that match search_query within search_index
    products = Product.find_products(search_query)

    return render_template("product_listing.html",
                           query=search_query,
                           products=products)
def search_products():
    

    search_query = request.args.get('query')

    
    products = Product.find_products(search_query)

    return render_template("product_listing.html",
                           query=search_query,
                           products=products)