Search

The strange this is, when I index the section then refresh the page - the number of indexed entries doubles, or triples. Is that supposed to happen?

This is a known bug. Try selecting the row then clicking “Re-Index” from the With Selected. This will delete the existing indexed entries and start the re-indexing. Just refreshing the re-index page will re-index without first deleting the indexed entries!

I should have paid more attention to the previous posts. I updated the extension and it works like a charm now, it was version 0.3a :s

Cheers Nick!

@nickdunn - I installed the Search Index extension, and installed without issue. There was one exception to that, the Search Index Logs item gives you a Fatal error if your database your are using a different table name prefix than sym_.

In the searchindex/lib/class.searchindex.php file, the table name is explicitly sym_search_index_logs and if you change the prefix from sym to tbl it fixes the errors.

NOTE: I’ve posted this as an issue.

Damn! I always forget to change those after copying from Sequel Pro. I have a few other things to go into the next release so this in the list, cheers,

Hey Nick, AMAZING extension - it works so well! Two questions:

1) You posted this entry earlier in this thread: added additional indexes to symsearchindex and symsearchindexlogs for mega performance improvement for single-section search, it is recommended you make sure indexes in your tables match these: symsearchindex: KEY ‘entryid’ (‘entryid’) and FULLTEXT KEY ‘data’ (‘data’) symsearchindexlogs: FULLTEXT KEY ‘keywords’ (‘keywords’)

How do I get to those indexes in my tables to verify the information matches?

2) I am trying to setup Site Search through Google Analytics. For the data field “Query Parameter (required):” should I enter ‘keywords’ ? And do you recommend that I choose the option, “No, do not strip query parameters out of URL” ?

As always, thank you!!!

If you view your database in a MySQL client such as Sequel Pro or phpMyAdmin then you can see the indexes when you view the search index table. See the screenshot below, there are two “non unique” indexes, one on entry_id and one on data. It is the entry_id index that was added later.

Sequel Pro screenshot

do you recommend that I choose the option, “No, do not strip query parameters out of URL”?

I think so, yes. This just tells it to use the one “keywords” parameter and to ignore all others.

should I enter ‘keywords’

If this is what you’re using on your site (/search-page/?keywords=... is the extension default) then yes.

This extension seems like a great addition but I’m having problems getting it to work with either a single data source or as a full site search.

I’ve created my search indexes and re-indexed (does this need to be updated when new records are added?) then attached the data source to a Search page (should there be a URL parameter added to the page?). I then included the example search form taken from the docs - and then this is where I come unstuck

Do you need to use Symphony events or Form Controls (not too familiar with either). The docs mention using $ds-search in other Data Sources so would you create a new page for Results, attaching all datasources then filtering with $ds-search?

Sorry if this is a bit of a basic question!

I’ve created my search indexes and re-indexed (does this need to be updated when new records are added?)

Nope, the index will update itself when you create/edit an entry. The re-indexing functionality is there for if you create an index when entries already exist, or if you’re not convinced that the entries are indexing themselves properly ;-)

Do you need to use Symphony events or Form Controls

Neither. The Search data source that comes with this extension is all that you need for multi-section searching. You don’t need a page URL Parameter, unless you’ve manually configured it to work that way. By default the data source listens for GET parameters. So if you’re using the form in the README you might have a search page URL like:

/my-search-page/?keywords=zombies&sections=articles,comments

If you also append &debug to the URL you should see the XML output of the search data source. Hopefully it will have found some entries, and you’ll see these in the XML along with the excerpt text (with the search terms highlighted).

The first step is to iterate over these in your XSLT and write out this value.

But all this gives you is the entry ID, excerpt text, and the section in which the entry lives. The search data source doesn’t know anything more about the entry. To get more about each entry, you need to take the $ds-search that the search data source creates (which is a list of the entry IDs it finds) and use it to filter another data source.

So in the above example you might be searching two sections: Articles and Comments. The $ds-search value contains IDs of entries from both of these sections. You would want to create two new data sources, one for Articles and one for Comments, filtering System ID by the $ds-search parameter:

{$ds-search}

Attach these two data sources to the page (so there are three attached) and they will get you more data for the entries found in the search. Then use XSLT to cross-reference between the XML results and build your search results page. This way, you can render an Article result one way (perhaps the article title, content and date) and a Comment the other (a gravatar image, name and comment text).

If you’re not seeing any entries returned from the first search data source, then something could be wrong.

Sorry if this is a bit of a basic question!

No worries. If something isn’t obvious from the README then let me know where the hole is. It was a challenge to document something so complex in a single README!

Thanks so much Nick - seems to be working now! I think I became confused after creating the form and testing it, I couldn’t get debug to work so I couldn’t tell whether it was or wasn’t working, and how it was structured. I was trying appending ?debug when I seemed to need &debug instead.

A couple of other quick questions though: when I land on the search page it shows all entries, unfiltered. I think this is because I’m not cross-referencing results, rather I’m just looping through the 2 results data sources - since I wasn’t sure how to do that either.

My other question is how to handle unusual strings, for example some of my fields contain a lot of underscores, depending on how the data is entered. So for example a search for ‘record’ won’t pick up NameOfRecord, even when * is used. Is this just a limitation or is there a way for me to adjust the search for data like this?

Thanks again!

In addition to the question above, I was wondering if there’s a way to paginate results when using a single data source. I’ve managed to get pages to display by using the URL /section/1/?keywords=x but a) not sure if that’s the best way and b) not sure how you’d use that to populate the pagination

Thanks a lot

I was wondering if there’s a way to paginate results when using a single data source

I don’t really understand. If you’re using a normal data source and filtering on the search index field (i.e. not using the Search Index data source) then pagination will work as usual, like any other data source.

some of my fields contain a lot of underscores, depending on how the data is entered. So for example a search for ‘record’ won’t pick up Name_ Of_ Record, even when * is used. Is this just a limitation or is there a way for me to adjust the search for data like this?

A limitation. Wildcard only adds the wildcard to the end of the string. So searching for “name” should find it, but “record” not. If you want in-word matching like this then I think you may want to investigate REGEXP: matching in SQL. But the extension doesn’t allow for this yet.

Cheers for the replies Nick, much appreciated. I’m using a single data source with the {$url-keywords} filter and a simple get form for ‘keywords’. The pagination seems to look correct, ie. the right number of pages (in both the xml and the displayed pagination) but clicking one just reverts to the unfiltered data, paginated e.g. /section/2/ rather than /section/2/&keywords=xxx

Sorry if that’s unclear, perhaps I’m missing something obvious!

I’m guessing the /2/ in your URL is a URL Parameter (set in your Page in Symphony) called something like {$page}? Therefore in the data source you need to add this to the “Show a maximum of {$page} results per page” box.

I’ve already got {$url-keywords} in the ‘show page’ box and pagination is working fine, but not with the search keywords - ie. clicking a page number or prev/next simply shows the page as if no search keywords were set, so the URL is /section/2/ after clicking a page but /section/2/&keywords=xx returns the desired results. Hope that makes sense, thanks for helping

Hmm kind of makes sense. So the prev/next links don’t pass the keywords on the end of the URL? How are you building the prev/next links? With the pagination XSLT utility? Are you adding ?keywords={$url-keywords} into the string when building the URL?

I’m trying to work out whether this is a bug with the extension, or that you’re implementing it wrongly.

I think it’s just me :)

I’ve managed to fix it by using this parameter, as suggested:

<xsl:with-param name="pagination-url" select="concat('/articles/$?keywords=', $url-keywords)" />

This does the job, though it always appends &keywords= even if no search is performed, so I may make a search subpage.

You could choose to write the keywords parameter only if it’s in use:

<xsl:with-param name="pagination-url">
    <xsl:value-of select="'/articles/$/'"/>
    <xsl:if test="$url-keywords=''">
        <xsl:value-of select="concat('?keywords=', $url-keywords)"/>
    </xsl:if>
</xsl:with-param>

Ah I didn’t think about that, perfect! I just made one small tweak and that is switching:

<xsl:if test="$url-keywords=''">

to:

 <xsl:if test != "$url-keywords=''">

Cheers for the help (again)

How to give link to the search results for eg if am searching for a name called "nick" means the result should have search result nick with anchor tag so that i can navigate through that

how to achieve this ?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details