Support » Plugin: Relevanssi - A Better Search » Can I search in POD fields?

Viewing 13 replies - 1 through 13 (of 13 total)
  • What type of Pod did you create? If you create Custom Post Types and keep it Meta-based for storage, Relevanssi will have no problem indexing it.

    We’re open to working with Relevanssi to further index other Pods and table-based fields too, if they’re open to that discussion. We’d just need a little direction on how to give Relevanssi what they’d need, so knowing functions/hooks to use would be helpful in that.

    Thanx for your answer. I have to check that. I just istalled Relevanssi, so perhaps we can make it work like you told me.

    Plugin Author Mikko Saari

    (@msaari)

    Relevanssi cannot index content stored in arbitrary tables – I’ve looked into it, and it’s just too complicated.

    Relevanssi can index post types, taxonomy terms and additional MySQL columns in wp_posts table (these last two only in Premium).

    Mikko, how can plugins integrate with Relevanssi and pass it:

    • URL
    • Title
    • Content

    Is that even possible, or is that not something Relevanssi can handle? I’m open to building Relevanssi integration into Pods core, so let me know if you can point me in the right direction.

    Plugin Author Mikko Saari

    (@msaari)

    It’s more complicated than that. To make Relevanssi index something else than posts, following is needed:

    – a function that goes through the content and passes each item to an indexer
    – an indexer that indexes the items: tokenizes the content, builds the INSERT queries and runs them
    – a function that deletes items from the Relevanssi index
    – a function that creates post objects from the items
    – action hooks that trigger when items are created, edited or deleted, so Relevanssi can re-index or delete when necessary

    I’ve done this for user profiles and taxonomy terms, so the infrastructure is there – in Relevanssi Premium – and it’s probably not impossible to do, just a wee bit complicated.

    Doesn’t sound too complicated to me, any way I could get a copy of Relevanssi Premium for integration with Pods? I’ve committed some tweaks to Pods 2.3 that makes this a lot easier on our side.

    Thanks for the answers. I fixed our problem by making a custom search page that does the job with POD queries (PHP). So we don’t use an indexed search now. At this moment that is enough for us. Would be nice if this could be integrated with the content indexing process in the future.

    Plugin Author Mikko Saari

    (@msaari)

    Scott, drop me an email to mikko @ mikkosaari.fi.

    @mweyburg can you share the code you used. A working sample would help me and other I’m sure as this is a common question for PODs users.

    mweyburg

    (@mweyburg)

    sure…..

    I’ve created a couple of search boxes on a wordpress page that does a call to a POD page URL including query string parameters. These query string parameters are the values that the user has typed in the search box.
    I have 3 search boxes: name (the name of a person), zipcode and city.
    I also created a POD page where I received those query string parameters. The query string parameters are used in the search query.
    It is pretty straightforward. Not a real fancy search, but it works for us.

    This is the code we have on our POD Page (next post):

    mweyburg

    (@mweyburg)

    <?php
    $relid = pods_url_variable('relid', 'get');
    $nom = pods_url_variable('nom', 'get');
    $postal = pods_url_variable('postal', 'get');
    $ville = pods_url_variable('ville', 'get');
    ?>
    
    <form method="get" id="searchform" action="/kap/searchresultrelations">
        <div><div>Identifiant rapport </div>  <input type="text" size="18" value="<?php echo wp_specialchars($relid, 1); ?>" name="relid" id="relid" /> </div>
        <div><div>Nom </div><input type="text" size="18" value="<?php echo wp_specialchars($nom, 1); ?>" name="nom" id="nom" /> </div>
        <div><div>Code postal </div><input type="text" size="18" value="<?php echo wp_specialchars($postal, 1); ?>" name="postal" id="postal" /> </div>
            <div><div>Ville </div><input type="text" size="18" value="<?php echo wp_specialchars($ville, 1); ?>" name="ville" id="ville" />
    <input type="submit" id="searchsubmit" value="rechercher relation" class="btn" />
    </div>
    </form>
    
    <?php
    pdf24Plugin_begin();
    
    ?>
    
    <table>
    <?php
    $relations = new Pod('relation');
    
    if ($relid != "" && is_numeric($relid)) {
        $params = array('where' => ' relationid = ' . $relid);
    }
    else
    {
    
     if ($nom !="")
         $nompart = ' name LIKE "%' . $nom . '%" ';
     if ($postal !="" && $nom !="")
         $postalpart = ' AND zipcode LIKE "%' . $postal . '%" ';
     if ($postal !="" && $nom ="")
         $postalpart = ' zipcode LIKE "%' . $postal . '%" ';
      if ($ville !="" && $postal !="")
         $citypart = ' AND city LIKE "%' . $ville . '%" ';
     if ($ville !="" && $postal =="" && $nom !="")
         $citypart = ' AND city LIKE "%' . $ville . '%" ';
     if ($ville !="" && $postal =="" && $nom =="")
         $citypart = ' city LIKE "%' . $ville . '%" ';
    
    $params = array('where' => $nompart . $postalpart  . $citypart);
    }
    $relations->findRecords($params, 20);
    echo $relations->showTemplate("relations_searchresult");
    ?>
    </table>
    <?php
    echo $relations->getPagination();
    ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    mweyburg

    (@mweyburg)

    We also have the searchboxes on this pod page as you can see in this part of the code:

    <form method="get" id="searchform" action="/kap/searchresultrelations">
    <div><div>Identifiant rapport </div> <input type="text" size="18" value="<?php echo wp_specialchars($relid, 1); ?>" name="relid" id="relid" /> </div>
    <div><div>Nom </div><input type="text" size="18" value="<?php echo wp_specialchars($nom, 1); ?>" name="nom" id="nom" /> </div>
    <div><div>Code postal </div><input type="text" size="18" value="<?php echo wp_specialchars($postal, 1); ?>" name="postal" id="postal" /> </div>
    <div><div>Ville </div><input type="text" size="18" value="<?php echo wp_specialchars($ville, 1); ?>" name="ville" id="ville" />
    <input type="submit" id="searchsubmit" value="rechercher relation" class="btn" />
    </div>
    </form>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    kutu62

    (@kutu62)

    thank you! will work on this right now!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Can I search in POD fields?’ is closed to new replies.