• Hi,

    I would like to implement most basic faceted search on my site.

    Example:

    a) audi, bmw
    b) green, red
    c) new, used

    I would like person to be able to click 3 things here, for example:
    bmw
    green
    new

    Is there a way to implement this without the plugin?

    Seems such a basic and important thing that wp should have this functionality.

    If not – does ebery free search plugin has this functionality (again it seems so common and basic that it should be mandatory for all plugin developers to include it)

    What is the real situation?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Can you show us your website? It’s base on a woocommerce website? There are many free woocommerce product filter plugin you can use to implement the search features on your website.

    Thread Starter expozitum

    (@expozitum)

    Hi, this is based on default wp template. It is simple directory site where I want people to be able to filter better (first layer company type, second layer company city etc)

    Like:
    a) design company, software company, logistics company
    b) Us, UK, Canada

    User would look for US design companies by clicking “design company” within first layer and “US” withion second layer.

    • This reply was modified 5 years, 3 months ago by expozitum.
    Moderator bcworkz

    (@bcworkz)

    If you want to merely combine search terms that should all match within title or content fields, you can just concatenate each term in a standard search query:
    example.com?s=used+green+audi

    If you want results that have any one term of several in any combination, it gets more difficult. And/or if some of the search terms lie in different fields, such as custom fields, things get further complicated.

    There are a whole bunch of extended search plugins that might meet your needs. It’s worth a little exploration before embarking upon your own coding project.

    The general solution in any case is to collect user selections, then either make an Ajax request or POST data to a page that can process such data and return the results. In many cases, a proper WP_Query object can handle the submitted search terms. Your code needs to parse the posted data into proper WP_Query arguments. In some cases, the nature of the search may be beyond the capabilities of WP_Query. You may need to create your own SQL query (using global $wpdb methods) in order to get the desired results.

    In composing WP_Query search arguments, keep in mind that the usual relational logic used with multiple terms is AND. Unless there is a specific OR option, the logic used will be AND. If you require OR logic where no such option is available, you will need to compose your own SQL query.

    Thread Starter expozitum

    (@expozitum)

    Your first option would not work because it also would find words in the text that were not meant to be assigned as “tags”.

    For example the word “green” can be found with the page of red audi.
    For example text: this red audi looks nice on green grass.

    I would need to filter specifically via assigned tags (in this case this page would be assigned “audi” in first layer and “red” in second layer.

    It sounds so so basic task that i can not imagine any free search plugin not having this. Yet it seems it is not so easy to find. Very strange for such a basic basic filtering need.

    Ps: when I say tags I do not necessary mean tags in an actual sense what they are in WP. I mean in general term that I would assigne these to the page/post in order to be filtered by them (as opposed to searching for any word in a text by search)

    • This reply was modified 5 years, 3 months ago by expozitum.
    Moderator bcworkz

    (@bcworkz)

    Yeah, full text searches have shortcomings. From what you’ve said you want something like tags, but not the actual default WP tags. Then a custom taxonomy? There’s really only 3 general choices: full text, taxonomy, or custom fields. Custom field searches are pretty inefficient. We know the issues with full text.

    As a taxonomy, I’d expect extended search plugins to support it, but I’ve no direct experience. Failing that, doing a search with WP_Query using custom taxonomy criteria is fairly straight forward.

    Thread Starter expozitum

    (@expozitum)

    Hi,
    it is easiest to explain with an example.
    Here is sketch of directory site:

    View post on imgur.com

    In this example is ice cream shop directory.
    On the left you see sidebar where visitor would filter ice cream shops by:
    1 layer – home made ; mass produced (ice cream)
    2 layer – taste/flavor : vanila, chocolate etc
    3 layer – location of the shop.

    So lets say yo uar ea visitor and you want to find ice cream shop that sells:
    home made ice cream
    chocolate
    in london

    You click all these three tags accordingly at the side bar and get displayed only entries (ice cream shops) that meets this criteria. In this limited example it would be shop “name 2” that would meet the clicked criteria.

    Super super basic/crucial navigation for any directory site.

    Moderator bcworkz

    (@bcworkz)

    OK, sure, that’s a classic taxonomy example. You can use categories, tags, or your own custom taxonomies. All terms can belong to one taxonomy or several. As you say, pretty common stuff. I would think there are plugins that would manage it for you. Try out a few listed in the link.

    A custom solution could be developed. Most of the work would be in developing the UI. Getting matching posts is relatively simple once you’ve collected the term IDs of the user selections into any array. For example, using tags:
    $query = new WP_Query(['tag__in' => $selections,]);
    Then run a loop on the $query object to list the matching posts.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Faceted search implementation? Free plugin or no plugin?’ is closed to new replies.