Advertisement:

Author Topic: Search doesn't work on multi language site?  (Read 3368 times)

skr678

  • Jr. Member
  • **
  • Posts: 52
Search doesn't work on multi language site?
« on: June 08, 2013, 08:59:37 pm »
I am trying to build a two language site and have the drop down language box with 2 languages installed.

If I have the 2nd language enabled and do a search, either in english (default) or the 2nd language, nothing comes up. I can put the exact title of the listing and it wont show up if I have the 2nd language enabled. 

What's weird is that on the search results page that says no results, if I switch to english on the same page, there are results!

What could I be doing wrong where the search results aren't coming up if I have the 2nd language enabled?

skr678

  • Jr. Member
  • **
  • Posts: 52
Re: Search doesn't work on multi language site?
« Reply #1 on: June 08, 2013, 11:37:51 pm »
Ok looking at it some more, this is what I was able to sort of figure out...

1. Not being able to search in asian language seems to be an issue with mysql and there doesn't really seem to be a "fix" for it.

2. This is what I am really confused about.....

When more than one language is installed, in the ad publish page there is a tab at the top of the text field for publishing ad.  The tab lets you choose the default language (english in my case) and the 2nd language (chinese in my case) for the text field.

IF I publish an ad by entering the ad text in the text field with the english tab, then that ad only shows up in search if I have the english language selected from the dropdown language selector.  On the search results page, if I select the 2nd language from the dropdown language selector, the ad disappears.

Similarly, IF I publish an ad by entering the ad text in the text field with the 2nd language tab chosen, then that ad only shows up if I have the 2nd language chosen from the dropdown language selector.  (NOTE: I am doing the search in english in both cases and entering the ad in english in both cases.  If I publish the ad in chinese, then that ad is basically not searchable in either case)

So, it seems like depending on the language chosen from the language tab above the text field when publishing the ad, ads some how get catgorized based on that chosen language.

What is the purpose of the two language choice tabs when publishing the ad? 

It's almost like two separate sites depending on language chosen in terms of being able to search.  Is there a way so that regardless of which language tab is chosen when entering the ad, that ad isn't tied to the language chosen in the language dropdown selector?

Thanks for your help!


« Last Edit: June 08, 2013, 11:40:45 pm by skr678 »

skr678

  • Jr. Member
  • **
  • Posts: 52
Re: Search doesn't work on multi language site?
« Reply #2 on: June 09, 2013, 02:12:37 am »
It seems like it's because of this part?

Quote
<input id="title[en_US]" type="text" name="title[en_US]" value="" />

It seems like based on the language tab chosen when entering the ad, it creates a different title that is tied to the language?

Does anyone know what the purpose of that is?  I am really confused why there needs to be two tabs for language input when posting an ad.

I can search for the ads based on price and they all show up in search results whether language chosen. But because of the above, it doesn't seem to search the title unless it is somehow tagged with the language that is currently chosen.

I can't figure out if this is a bug or if there's a reason that it is set up this way.  And how I can resolve it so that people can search all the ads.

Please anyone with more expertise help! :)

skr678

  • Jr. Member
  • **
  • Posts: 52
Re: Search doesn't work on multi language site?
« Reply #3 on: June 09, 2013, 03:35:21 am »
well....I now understand why there are language tabs when posting ad and why it only searches based on locale code that is "set" by selecting the language from the dropdown selector.  For those few who are trying to run a dual language site and as confused as I was about how it works...

1. For each language installed, a new tab for that language appears above the title and description input fields when posting an ad. The tab allows the poster to choose a particular language.  I believe this is so that the user can post an ad in multiple languages. And depending on which tab the poster chooses, the title and description is "tied" to that language locale code.  If a poster enters title and description for each tab (i.e. language), then that ad would have title and description for each language each marked with its respective locale code in the db.  (Note: mysql settings allowing, the poster can post the same ad in same language for all language choices...i think db has to be set to utf-8? I'm a complete novice so whatever Im posting here are just my guesses based on what I was able to figure out)

Looking at the db, each ad post generates one "row" of data for each language.  They all have the same fk_i_item_id, then each with its own fk_c_locale_code, and s_title and s_description with whatever the poster filled in in that particular language tab input field.

So if a user only entered title and description under the english tab when posting the ad, all the other language title and description cells will be  empty.  Or if they only entered title and descrip in one of the other available languages, the the other language cells will be empty, etc.

2. The above seems to work fine and gives the user another choice in how they present the ad (i.e multiple languages).  The problem seems to come in when doing a search based on title and description.  Currently when a visitor does a search from the main search box, it will SHOW only those matching ads IF it has title and description "tagged" with the language/locale code that matches the language code of the language currently in use by the visitor.  The search seems to return the ad because if I switch languages on the results page, the ad shows up.  In showing the ad, it seems like the ad is treated as individual ads for each language.  So I believe the logic is that if there wasn't this filter, the same ad could show up multiple times in search if the poster posted a title and description in multiple languages or in the same language multiple times under each language tab.

I believe the way it works right now needs an additional step for sites running multiple languages.

1. Is there a way to have it so that

search shows all the results as long as it has a unique fk_i_item_id
if there are multiple instances of title and description for one item id, show the one that matches the fk_c_locale_code of the user (I believe it's already doing this by default if I'm not mistaken).

So by showing all the ads that have unique item id, it would return ads regardless of language chosen by the visitor.

OR

2. If 1 isn't possible, is there a way to check during ad posting and populating the title and description cells of the other languages if they are left empty by the poster?

If you've read all this, I thank you!  If you can point me in the right direction, I love you! :D

will only search title and description cells of a single language/locale code (which is set when the user selects the language from the dropdown selector or by default based on default language).  If those cells are empty for that language/locale code, then the search results doesn't SHOW that ad. 


Since there are in effect mutliple instances of the ad in the db based on language/locale code,


glaksmono

  • Newbie
  • *
  • Posts: 4
Re: Search doesn't work on multi language site?
« Reply #4 on: May 05, 2014, 06:12:33 am »
seems like the problem i'm encountering right now.. thoughts?

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
Re: Search doesn't work on multi language site?
« Reply #5 on: April 08, 2015, 10:33:25 am »
I had found a simple solution just we need to comment locale_code line in search.php in model of osclass

Just follow this oc-includes/osclass/model/search.php

Comment on line 807 &  926


SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Search doesn't work on multi language site?
« Reply #6 on: April 27, 2015, 03:06:39 pm »
Hi Abhi143ull,

it looks like this works 100% but it actually does not, in case someone does a text search several ads will show up as duplicates.
I don't know why but for others it is good to know that this is not 100% as without the commented out lines text search is working 100% but with the inconvenience of items only shown in the selected locale.


Regards,
Eric

whumphreys

  • Newbie
  • *
  • Posts: 2
Re: Search doesn't work on multi language site?
« Reply #7 on: June 14, 2016, 10:59:54 pm »
has someone fixed it, im having the same issue getting duplicates

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Search doesn't work on multi language site?
« Reply #8 on: June 15, 2016, 01:14:08 pm »
Hi,

See here:

http://forums.osclass.org/3-5-x/search-problem-oc-3-5-3/msg113711/#msg113711

(There's another function below to add sorting by relevance also, if you're interested).

Regards