phpmongodbsolrlucidworks

Mongodb+Solr table relations for Ecommerce listings search


I've been working in an ecommerce application using mongodb. Now Im planning to Integrate my existing ecommerce infrastructure with solr to manage the display of products catalogs. My main idea is to incorporate the following functionalities: - Categorical Navigation - Faceting - Geo-Targeting - Auto Suggest

This is an example of the application layout I would like to recreate:

enter image description here

Currently I have the following collections in mongodb:

Products: {
    "_id" : ObjectId("568887fc14a9962460fbbcbd"),
    "date_created" : "2014-10-01T00:00:00Z",
    "date_updated" : "2014-10-01T00:00:00Z",
    "name" : "Iphone 6 64gb",
    "price" : "100",
    "summary" : "Iphone 6 64gb",
    "delivery" : "Shipment",
    "shipment_location" : "USA",
    "shipment_weight" : "1",
    "shipment_package_quantity" : "1",
    "options" : {
        "id" : "price-1234567890",
        "value" : "111",
        "stock_level" : "1",
        "currency" : "usd"
    },
    "attributes" : {
        "id" : "atr_1",
        "name" : "memory",
        "values" : "64gb"
    },
    "images" : {
        "id" : "price-1234567890",
        "caption" : "image",
        "file" : [ 
            {
                "id" : "price-1234567890-1",
                "date_uploaded" : "2014-10-01T00:00:00Z",
                "length" : "123",
                "md5" : "hasg",
                "filename" : "price-1234567890-1",
                "content_type" : "PNG",
                "metadata" : "price-1324567890-1",
                "data" : "price-1234567890-1",
                "url" : "/images/folder/mongodb/a.png"
            }
        ]
    },
    "category_id" : "65",
    "category_index" : {
        "id" : "111",
        "sort" : "price"
    },
    "stock" : {
        "id" : "price-1234567890",
        "date_created" : "2014-10-01T00:00:00Z",
        "date_updated" : "2014-10-01T00:00:00Z",
        "parent_id" : "",
        "parent" : "111",
        "number" : "111",
        "quantity" : "11",
        "variant_id" : "1",
        "variant" : "11",
        "last" : "1",
        "prev_id" : "1",
        "prev" : "1",
        "level" : "1",
        "reason" : "1",
        "description" : "1",
        "order_id" : "11",
        "order" : "1"
    },
    "quantity_min" : "1",
    "quantity_inc" : "1",
}

Categories Collection:

{
    "_id" : 3,
    "date_created" : "2016-01-01T00:00:00Z",
    "date_updated" : "2016-01-01T00:00:00Z",
    "name" : "Computers",
    "slug" : "Computers",
    "description" : "Computers",
    "meta_description" : "Computers",
    "meta_keyword" : "Computers",
    "navigation" : "true",
    "top_id" : 3,
    "top" : "true",
    "parent_id" : 2,
    "parent" : "Default",
    "active" : "y",
    "productype" : "simple",
    "path" : "Computers",
    "categoryids" : "2,3",
    "children" : "yes",
}

Taxonomy:

{
    "_id" : ObjectId("56803181bf244c701d000170"),
    "category_id" : "65",
    "name" : "Names",
    "expandable" : false,
    "inputAsTree" : true,
    "multiSelect" : true,
    "mandatory" : false,
    "version" : 9,
    "createTime" : 1451240000.0000000000000000,
    "lastUpdateTime" : 1451280000.0000000000000000,
}

Taxonomyterms collection:

{
    "_id" : ObjectId("568073e5bf244c701d000179"),
    "text" : "Jose",
    "version" : 2,
    "taxonomyid" : "56803181bf244c701d000170",
    "orderValue" : 1600,
    "expandable" : false,
    "nativeLanguage" : "en",
    "i18n" : {
        "en" : {
            "text" : "Jose",
            "locale" : "en"
        }
    },
}

Taxonomy terms refer to taxonomy. in the first one you can define the main name and in terms define the terms that have a relation with taxonomy (the options). eg: Taxonomy: Names. Taxonomy Terms: bob-jose-pedro

Could anyone shed some light what I have to do to approach the integration with the proposed schema of collections in mongo to design in solr:

how I can map categories with categorical navigation.? how can I map taxonomy-terms with faceting.? Does solr provides a setup-configuration area for facets?

or any different approach you believe could be better.


Solution

  • It sounds like this e-commerce application is custom-developed, and not hosted on a platform which might have a Solr connector, so this is going to require learning a lot about Solr, and doing a lot of custom-development on this search page.


    Your Solr Products collection will need to include the following fields at minimum:

    1. Product ID (for the purpose of linking back to the application, or querying mongo, etc...)
    2. All the text which you need to be searchable (either a field for every searchable text attribute, one big "text_search" field with all searchable text together, or something in between.)
    3. All the product attributes/fields that you need for sorting, filtering, scoring (and optionally, display) - you may choose to query mongo by Product ID to retrieve display information per search result.
    4. All the attributes on which you want facet counts (multivalued). This could include applicable category_slugs, taxonomy_terms and product attributes, such as colors, sizes, brand, local_availability and price.

    Think about your collection as an old-school denormalized/flattened view of all the Product (and related) data needed for Search.


    (a) Categorical Navigation: products across the entire virtual storefront with guided navigation.

    Check out Solr's Hierarchical Faceting page

    (b) Faceting: Auto-extract product information to enable customers to filter by color, size, brand, local availability, and price.

    Solr will generate facet counts for all values (present in search results) of a requested field. This means that you need to have one field for every facet-able attribute in your collection. And you'll have to define/map these directly.