[Skip to main content](#vessel-content)

#   Search order

##

- **[ians](/forum/user/7862-ians "View ians's Profile")**
- [![ians's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7862-ians "View ians's Profile") Topic Author
- [ Offline](/forum/user/7862-ians)

Less More

- Posts: 63
- Thank you received: 3
-
-

13 years 7 months ago [\#98246](#98246) by [ians](/forum/user/7862-ians "View ians's Profile")  *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#98246 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")* was created by *[ians](/forum/user/7862-ians "View ians's Profile")*

Hi there,

I'm having a slight problem with searches on my website:

[ www.wslr.co.uk/index.php/resources-catalogue](http://www.wslr.co.uk/index.php/resources-catalogue)

Question 1

The search is returning partial words - for instance if I do a text search for our planet, anything with the "our" contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.

I have the text search looking in product code, product keywords, product name, and product description.

Is there a way to make the search only see whole words?

Question 2

I would like to return the products in order of priority and I've set up a custom field named "order" and this will be 1,2,3 or 4

I'd like all order 1 to come up first, then order 2, and so on.

I've set the Default parameters for products ordering field to "order" which is my cistom field, but it doesn't seem to work in the way I expected.

How can I set all searches to return the product in order 1,2,3,4 etc

Hope this makes sense,

ian

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86578
- Thank you received: 14321
-
-

13 years 7 months ago [\#98383](#98383) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#98383 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

Hi,

1. You can change the line:
$list[]=' b.'.$column.' LIKE \'%'.hikashop_getEscaped($term, true).'%\' ';

to:
$list[]=' b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' ';

in the file administrator/components/com_hikashop/classes/filter.php to make sure there is a space before and after the words but then if the word is the first word of the field and thus doesn't have a space before or if if it has a dot or a comma after.

That might be possible with a more complex condition like that :
$list[]=' (b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \''.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).',%\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).'.%\')';
but it's still not perfect...

2. Change the "ordering field" in the hikashop options of your menu via the menu Display-&gt;Content menus and that should do it.

The following user(s) said Thank You: [ians](/forum/user/7862-ians "View ians's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ians](/forum/user/7862-ians "View ians's Profile")**
- [![ians's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7862-ians "View ians's Profile") Topic Author
- [ Offline](/forum/user/7862-ians)

Less More

- Posts: 63
- Thank you received: 3
-
-

13 years 7 months ago [\#98389](#98389) by [ians](/forum/user/7862-ians "View ians's Profile")  Replied by *[ians](/forum/user/7862-ians "View ians's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#98389 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

Thanks Nicolas,

For the search - I'll try changing the code as you suggest.

However, I was wondering if there could be another option?

If you include some words in commas in Google - like "our planet" it would find matching whole words. Is there a way to make this happen in HikaShop? This would also solve my problem.

Yours,

ian

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86578
- Thank you received: 14321
-
-

13 years 7 months ago [\#98521](#98521) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#98521 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

That's not possible.

We're simply using the LIKE feature of mysql to search for the text in the database. Google has a powerful search algorithm which is much much much more complex than what can be done with that LIKE feature.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ians](/forum/user/7862-ians "View ians's Profile")**
- [![ians's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7862-ians "View ians's Profile") Topic Author
- [ Offline](/forum/user/7862-ians)

Less More

- Posts: 63
- Thank you received: 3
-
-

13 years 7 months ago [\#98534](#98534) by [ians](/forum/user/7862-ians "View ians's Profile")  Replied by *[ians](/forum/user/7862-ians "View ians's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#98534 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

Hi Nicolas,

thank you for your help.

I applied the more complex condition and it seems to work.

I'll let you know how I get on with it.

You are a genius!!

Thanks

Ian

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ians](/forum/user/7862-ians "View ians's Profile")**
- [![ians's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7862-ians "View ians's Profile") Topic Author
- [ Offline](/forum/user/7862-ians)

Less More

- Posts: 63
- Thank you received: 3
-
-

13 years 7 months ago [\#99723](#99723) by [ians](/forum/user/7862-ians "View ians's Profile")  Replied by *[ians](/forum/user/7862-ians "View ians's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#99723 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

Hi Nicolas,

Many thanks for helping with the search in filters.

I've added the code you suggested and it has made a big difference:

$list[]=' (b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \''.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).',%\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).'.%\')';
but it's still not perfect...

It's not working quite as expected. If the product has a single word - no space before or after, it still doesnt show up in the search.

if i search for "dragonslayer" for instance which is the only word in the title - doesnt come up.

or if I search for it's product code "FD0810" it doesn't come up

product link is here:

[ www.wslr.co.uk/index.php/resources-catal...ow/1789-dragonslayer](http://www.wslr.co.uk/index.php/resources-catalogue/product/show/1789-dragonslayer)

Search page is here:

[ www.wslr.co.uk/index.php/resources-catalogue](http://www.wslr.co.uk/index.php/resources-catalogue)

do you have any suggestions?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

13 years 7 months ago -  13 years 7 months ago [\#99838](#99838) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#99838 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

Hi,

It's because you have some missing tests, like the search string itself: Code:

$searchEscaped = hikashop_getEscaped($term, true); $list[]=' (b.'.$column.' LIKE \'% '.$searchEscaped.' %\' OR b.'.$column.' LIKE \''.$searchEscaped.' %\' OR b.'.$column.' LIKE \'% '.$searchEscaped.',%\' OR b.'.$column.' LIKE \'% '.$searchEscaped.'.%\' OR b.'.$column.' LIKE \''.$searchEscaped.'\')';

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Last edit: 13 years 7 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ians](/forum/user/7862-ians "View ians's Profile")**
- [![ians's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7862-ians "View ians's Profile") Topic Author
- [ Offline](/forum/user/7862-ians)

Less More

- Posts: 63
- Thank you received: 3
-
-

13 years 7 months ago [\#99921](#99921) by [ians](/forum/user/7862-ians "View ians's Profile")  Replied by *[ians](/forum/user/7862-ians "View ians's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#99921 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

Hi Nicolas,

Ah, I see.

I just tried adding that code but it broke the shop (shop wouldn't load), so i must have added it to the wrong place.

Please could you clarify where the 2 bits of code go?

I replaced this:

$list[]=' b.'.$column.' LIKE \'%'.hikashop_getEscaped($term, true).'%\' ';

with this:

$list[]=' (b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \''.hikashop_getEscaped($term, true).' %\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).',%\' OR b.'.$column.' LIKE \'% '.hikashop_getEscaped($term, true).'.%\')';

and added this to it:

$searchEscaped = hikashop_getEscaped($term, true);
$list[]=' (b.'.$column.' LIKE \'% '.$searchEscaped.' %\' OR b.'.$column.' LIKE \''.$searchEscaped.' %\' OR b.'.$column.' LIKE \'% '.$searchEscaped.',%\' OR b.'.$column.' LIKE \'% '.$searchEscaped.'.%\' OR b.'.$column LIKE \''.$searchEscaped.'\')';

Appreciate your help,

Ian

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26401
- Thank you received: 4081
-
- [](http://obsi.dev)
-

13 years 7 months ago [\#100260](#100260) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Search order](/forum/2-general-talk-about-hikashop/80169-search-order#100260 "Hi there,  I'm having a slight problem with searches on my website:    www.wslr.co.uk/index.php/resources-catalogue  Question 1  The search is returning partial words - for instance if I do a text search for our planet, anything with the &quot;our&quot; contained in it is shown - like your, tour, flour etc etc which means many hundreds of products are returned.  I have the text search looking in product code, product keywords, product name, and product description.  Is there a way to make the search only see whole words?  Question 2  I would like to return the products in order of priority and I've set up a custom field named &quot;order&quot; and this will be 1,2,3 or 4  I'd like all order 1 to come up first, then order 2, and so on.  I've set the Default parameters for products ordering field to &quot;order&quot; which is my cistom field, but it doesn't seem to work in the way I expected.  How can I set all searches to return the product in order 1,2,3,4 etc  Hope this makes sense,  ian")*

Hi,

I have fix a missing quote in my previous post.
Please recopy it, it should be better.

Regards,
Jerome

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzgwMTY5LXNlYXJjaC1vcmRlcj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.063 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
