Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#61 2014-12-11 10:58:35

etc
Developer
Registered: 2010-11-11
Posts: 5,133
Website GitHub

Re: etc_search: when the default search is not enough

Hi Jakob, I’m unfortunately not familiar with smd_tags, but what about this *article*-type query:

ID IN(SELECT ID FROM textpattern WHERE {Title, Body} UNION ALL SELECT txp.ID FROM textpattern txp JOIN (smd_tags, smd_tags_used) ON (txp.ID=smd_tags_used.item_id AND smd_tags.id=smd_tags_used.tag_id) WHERE {smd_tags.name,smd_tags.title}) AND (Section != 'aktuelles' OR custom_n > '<txp:php>echo date("Y-m-d");</txp:php>')

You’ll probably have to increase etc_search.query size to varchar(512) before. And not sure about this query performance (if it works at all).

Offline

#62 2014-12-11 16:20:20

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: etc_search: when the default search is not enough

Brilliant! That (very nearly) nailed it. Thank you!

You’re right, I did need to increase etc_search.query size to varchar(512). I’m not using it as live search, and from a normal use perspective it’s okay speed-wise.

The only thing I’m not getting is LIKEsearch_term matches for the tags, e.g. a search for “stampflehm” does not match articles tagged with “stampflehmbau”, but a search for “stampflehmbau” does (of course).

TXP Builders – finely-crafted code, design and txp

Offline

#63 2014-12-11 20:54:51

etc
Developer
Registered: 2010-11-11
Posts: 5,133
Website GitHub

Re: etc_search: when the default search is not enough

jakob wrote #286443:

The only thing I’m not getting is LIKE “search_term” matches for the tags, e.g. a search for “stampflehm” does not match articles tagged with “stampflehmbau”, but a search for “stampflehmbau” does (of course).

If you mean SQL LIKE, it should be LIKE '%search_term%'. But you shouldn’t worry about it, since {smd_tags.name,smd_tags.title} will be automatically transformed by etc_search into

( smd_tags.name LIKE '%search_term%' OR smd_tags.title LIKE '%search_term%' )

If it doesn’t work, try to uncomment the line (remove <!-- --> if needed)

// $o[] = '<!-- '.$query.' -->';

to see what the final query is.

Offline

#64 2014-12-12 09:31:31

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,702
Website

Re: etc_search: when the default search is not enough

You’re right: it does exactly what you say.

After comparing the query output and doing a little more research, I found the answer: etc_search_results has a default limit of 10 and I guess other articles had a better score so the results I was expecting were not in the top ten. I did actually read, or rather mis-read, the docs: the default limit of 0 (no limit) applies only to etc_search but not to etc_search_results. Perhaps it would be worth adding that to the docs of the next version. Thanks again for your time and suggestions.


TXP Builders – finely-crafted code, design and txp

Offline

#65 2014-12-12 17:22:46

etc
Developer
Registered: 2010-11-11
Posts: 5,133
Website GitHub

Re: etc_search: when the default search is not enough

Sorry for the docs, I’m very bad at it. If the match score (relics of default core search order) is artificial in your situation, you can append ORDER BY Posted DESC to the query.

Offline

#66 2015-02-20 04:57:12

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: etc_search: when the default search is not enough

Hi etc,

i have started now again with textpattern (having making a long break).
Now I install your search-plugin, its very good.
So I wish to show the results in articles, I have resolved it.

In the testing for search results with 2 words I get results with one article. But there is an old result from the default search_results “if_search_results” no matching, then show: <txp:text item="no_search_matches" />and say me, there would not result,but in the line below is one result.
How i can changing the text for result matches?

Here is my snippet of the form etc_static_search_results:

 <txp:if_search>

<!-- count how many results return -->
  <txp:article limit="10" pgonly="1" />

  <txp:if_search_results>

<!-- if search result count greater than 200 then display excessive results message, otherwise show search result count -->
    <txp:if_search_results max="200">
      <h3><txp:etc_search_result_count />, Suchwort: <!-- <txp:text item="matching_search_request" /> --> &raquo;<txp:search_term />&laquo;</h3>
    <txp:else />
      <h3><txp:text item="too_common_search_term" /> &#8216;<txp:search_term />&#8217;</h3>
    </txp:etc_static_search_results>

<!-- if no search results, then display no search results message -->
  <txp:else />
    <h3><txp:text item="no_search_matches" /></h3>

  </txp:if_search_results>

<!-- display resulting articles (10 per page) -->
  <txp:etc_search_results id="1">

    <txp:if_first_article><ul id="article-list"></txp:if_first_article>
      <li role="article" itemscope itemtype="http://schema.org/Article">
        <h4 itemprop="name"><a href="<txp:permlink />" itemprop="url"><txp:title /></a></h4>

<!-- if the article has an excerpt, display that, otherwise show highlighted keywords in context of article -->
        <txp:if_excerpt>
          <div itemprop="description">
            <txp:excerpt />
          </div>
        <txp:else />
          <p><txp:etc_search_result_excerpt /></p>
        </txp:if_excerpt>

        <p class="footnote"><txp:text item="posted" /> <time datetime="<txp:posted format='iso8601' />" itemprop="datePublished"><txp:posted /></time></p>
      </li>
    <txp:if_last_article></ul></txp:if_last_article>

  </txp:etc_search_results>

Last edited by lythande (2015-02-20 04:57:52)

Offline

#67 2015-02-20 18:19:11

etc
Developer
Registered: 2010-11-11
Posts: 5,133
Website GitHub

Re: etc_search: when the default search is not enough

Hi lythande,

I guess, the problem comes from the initial <txp:article limit="10" pgonly="1" />. The core search engine does not detect any match, so if_search_results returns false, though etc_search finds something. So you should delete this <txp:article limit="10" pgonly="1" /> and invert the order of if_search_results and etc_search_results, storing the last one inside a variable:

 <txp:if_search>

<!-- count how many results and place them in a variable -->
  <txp:variable name="search_results">

  <txp:etc_search_results id="1">

    <txp:if_first_article><ul id="article-list"></txp:if_first_article>
      <li role="article" itemscope itemtype="http://schema.org/Article">
        <h4 itemprop="name"><a href="<txp:permlink />" itemprop="url"><txp:title /></a></h4>

<!-- if the article has an excerpt, display that, otherwise show highlighted keywords in context of article -->
        <txp:if_excerpt>
          <div itemprop="description">
            <txp:excerpt />
          </div>
        <txp:else />
          <p><txp:etc_search_result_excerpt /></p>
        </txp:if_excerpt>

        <p class="footnote"><txp:text item="posted" /> <time datetime="<txp:posted format='iso8601' />" itemprop="datePublished"><txp:posted /></time></p>
      </li>
    <txp:if_last_article></ul></txp:if_last_article>

  </txp:etc_search_results>

  </txp:variable>

  <txp:if_search_results>

<!-- if search result count greater than 200 then display excessive results message, otherwise show search result count -->
    <txp:if_search_results max="200">
      <h3><txp:etc_search_result_count />, Suchwort: <!-- <txp:text item="matching_search_request" /> --> &raquo;<txp:search_term />&laquo;</h3>
    <txp:else />
      <h3><txp:text item="too_common_search_term" /> &#8216;<txp:search_term />&#8217;</h3>
    </txp:if_search_results>

<!-- if no search results, then display no search results message -->
  <txp:else />
    <h3><txp:text item="no_search_matches" /></h3>

  </txp:if_search_results>

<!-- display resulting articles (10 per page) -->

  <txp:variable name="search_results" />

</txp:if_search>

Hope that helps, don’t hesitate to shout at me otherwise.

Offline

#68 2015-02-20 20:50:51

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: etc_search: when the default search is not enough

Hi etc,

much thanks, I have try out this and it works, great! :)
I has thought too, that the <txp:article limit="10" pgonly="1" /> making this “error”, but I having not know, how making better. Much thanks!!!

Lythande

Last edited by lythande (2015-02-20 20:52:52)

Offline

#69 2015-06-27 01:07:18

lazlo
Member
Registered: 2004-02-24
Posts: 110

Re: etc_search: when the default search is not enough

Hi Oleg, on another thread you helped me with the search problem listed below quite successfully. Thank You
As I rewrite the code I am need of your help again.

I am now in the process of updating and moving away from “Author_1, Author_2, Author_3” individual custom fields (problem as listed below) and moving to a single custom field text area called Contributors.
The format would be like this:

First Name|Last Name|Full Name|Full Name Inverted|Corporate|Role|Country|Contibutor_URL| EOL Char
Joe|Blow|Joe Blow|Blow, Joe|Unused|Author|CA|joe-blow|EOL Char
Jane|Doe|Jane Doe|Doe, Jane|Unused|Editor|CA|jane-doe|EOL Char

additionally probably formatted with Jquery like this tip:
http://txptips.com/create-your-own-custom-ui-in-the-write-tab

The problem now exists is that I am not quite sure how to translate your etc_search using Rah_repeat.
I want search the Contributor Field for all instances of the same “Full Name” so I believe I assign a the Full_Name variable using Rah_repeat but then how do I use etc_search to find all instances?

regards
Les

etc wrote #284694:

Ah, you want to output the books having the current Author_1 (say, custom_1) or Editor_1 (custom_11) as contributors? This should work:

create an article-type etc_search query (say, id=1) with {"OR":";"} as logical operators, and

{custom_1,custom_11} AND Section='Books' AND ID != <txp:page_url type="id" /> ORDER BY custom_4 DESC...

as query string. Then add this to the individual article form:

<txp:etc_search_results id="1" form="book_title" limit="40"...

It will internally transform it into

... WHERE ( (custom_1 LIKE '%Author_1%' OR custom_11 LIKE '%Author_1%')...

and ignore empty contributor fields.

p.

Offline

#70 2015-06-27 09:46:19

etc
Developer
Registered: 2010-11-11
Posts: 5,133
Website GitHub

Re: etc_search: when the default search is not enough

Hi Les, it depends on what rah_repeat will output. Assuming that it’s Joe Blow;Jane Doe in your case (I leave it with you), and Contributors field is custom_1, try to modify the etc_search query as

{custom_1 LIKE '%|$0|%'} AND Section='Books' AND ID != <txp:article_id /> ORDER BY ...

and call <txp:etc_search_results id="1" query='<txp:variable name="contributors" />' /> as before. It will look for

(custom_1 LIKE '%|Joe Blow|%' OR custom_1 LIKE '%|Jane Doe|%')

Edit: actually, the upcoming v.0.9.6 brings more powerful query splitting, you’ll probably not need rah_repeat here. It lacks docs to be relased, let me know if you want to test it.

Last edited by etc (2015-06-27 10:28:41)

Offline

#71 2015-06-27 16:59:41

lazlo
Member
Registered: 2004-02-24
Posts: 110

Re: etc_search: when the default search is not enough

Hi Oleg

I would be happy to test out v.0.9.6, I am on the Textpattern version: 4.5.7 (r5900) PHP 4.5.3 if that matters at all. You can send it along to typesmith@gmail.com or point me to where I can grab it.

The Contributor field (custom field text area) contains data exactly like this.

A01|By|Caymar Chai|Chai, Caymar |Chai|Camyar |CA||
A01|By|Guillermo Verdecchia|Verdecchia, Guillermo |Verdecchia|Guillermo |CA||
A01|By|Marcus Youssef|Youssef, Marcus|Youssef|Marcus|CA||
B01|Edited by|Sherrill Grace|Grace, Sherrill|Grace|Sherrill|CA||
B02|Translated by|Albert-Reiner Glaap|Glaap, Albert-Reiner|Glaap| Albert-Reiner|CA||

I need to search other contributor fields to find out matching names of Authors, Editors, Translators, Photographers, etc by unique contributor role (A01, B01, B02).

I don’t know if it would be best to do this in one call or many but I will try to explain the results.
A book authored by Caymar Chai and Guillermo Verdecchia and Marcus Youssef is displayed.

I need a list of any other books that Caymar Chai has worked on by contributor role.
So grab Caymar Chai if his name exist in other contributors lists and grab and sort by contributor role, then output list with contributor role text (By, Edited By, Translated By).

Output would look like
Other books By Caymar Chai
(Book List)
Other Books Edited by Caymar Chai
(Book List)
Other Books Translated by Caymar Chai
(Book List)

Does this make sense?

Offline

#72 2015-06-28 13:52:33

etc
Developer
Registered: 2010-11-11
Posts: 5,133
Website GitHub

Re: etc_search: when the default search is not enough

lazlo wrote #292171:

I need to search other contributor fields to find out matching names of Authors, Editors, Translators, Photographers, etc by unique contributor role (A01, B01, B02).

Output would look like
Other books By Caymar Chai
(Book List)
Other Books Edited by Caymar Chai
(Book List)
Other Books Translated by Caymar Chai
(Book List)

Do you need this for the first author only, or for all authors or even for all contributors? That looks tricky to do in one go even in plain SQL, but I may be wrong. A clever query, anyone?

Last edited by etc (2015-06-28 13:53:50)

Offline

Board footer

Powered by FluxBB