Advertisement:

Author Topic: Custom field search  (Read 5455 times)

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #90 on: March 24, 2019, 09:05:34 pm »
Are you sure that item has custom fields?

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #91 on: March 25, 2019, 12:19:43 am »
Are you sure that item has custom fields?

Yes!

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #92 on: March 27, 2019, 12:19:20 am »
@marius-ciclistu
now i added mc_hide_metas() before main function in functions.php and it worked!
and in item-post.php i put this: <?php ItemForm::description_textarea('description',osc_current_user_locale(), osc_esc_html( mc_hide_metas(bender_item_description(), osc_item_id()) )); ?>
but now there is a few problems,
1. what should i do to put only custom-fields that has value! because it put all the custom-fields in description!
2. it doesn't remove custom-fields when i see a listing or edit a listing!
3. when i edit the item, and edit custom-fields, it does not update custom-fields in description!
Thanks,

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #93 on: March 27, 2019, 11:49:25 am »
Use just like in item post, the hide metas in the other 2 places.

You see? If you want you can do it yourself:)

To remove the empty metas, search in google how to test array value or any other question you have, and you will learn to do it your self:)

Follow removeunderline from my ft min word len solution to find the places where you should hide metas.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #94 on: August 05, 2019, 09:04:15 pm »

@marius-ciclistu
I have a question about your second solution!
Can i ask?

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #95 on: August 06, 2019, 09:10:43 am »
Can you?:)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #96 on: August 06, 2019, 09:53:21 am »
@marius-ciclistu
Thank you very much!
With your second solution everything work good. It has only one problem. When i search for example ( android phone ), it shows the results of all title and description and also custom-fields. which is good. But when i search ( "android phone" ), it only shows the results of title and description. But dosnt include the custom-fields search in the result.
How can i fix this to include also custom-fields search in the result when i use double quotation marks?
By the way, double quotation marks is for searching the exact phrase.
And also let you know that i'm using Teseo's (wildcard) and (search in all languages) functions.
Thank you!

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #97 on: August 06, 2019, 05:29:25 pm »
Those work or worked in google. I think osclass searches for "android and phone" , so the quotes are included in the word. If there is that functionality in your code maybe you don't have andoid phone as a custom field value.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #98 on: August 06, 2019, 09:16:52 pm »
@marius-ciclistu
Osclass has this functionality! Like google.
I tried also on osclass general demo and worked:

( have for sale ):
https://demo.osclass.org/general/search/pattern,have+for+sale

( "have for sale" ):
https://demo.osclass.org/general/search/pattern,%22have+for+sale%22

Please try these url above and see that is working.

I do have (android phone) in my custom-fields. And it shows in my search results if i search without double quotes.
« Last Edit: August 06, 2019, 09:21:47 pm by Sophia_OS »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #99 on: August 06, 2019, 10:03:57 pm »
https://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html

In the bottom of the page.
That means that maybe the custom fields are searched with the words containing the " characters, as they are not full text search columns (https://doc.osclass.org/Fine-Tuning_MySQL_Full-Text_Search_-_Improving_search)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #100 on: August 06, 2019, 10:21:00 pm »
@marius-ciclistu
If you test your solution number2, you can see that search method for both (title, description) and (custom-fields) are the same. Check the core file.
I think we could fix this by editing the _makeSQL function!
Please take a look at this code that you gave us. And see if you could fix by editing the _makeSQL function:

https://forums.osclass.org/development/please-help-to-do-this/msg163268/#msg163268

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #101 on: August 06, 2019, 10:48:01 pm »
I updated the solution from theme.

mods are

Code: [Select]
                    $customfieldCond = '';
                    $trimmedSPattern = trim($this->sPattern);
                    if (!(substr($trimmedSPattern, 0, 1) === '"' && substr($trimmedSPattern, strlen($trimmedSPattern)-1, 1) === '"')) {
                      $explodePattern = explode(' ', str_replace('+', '', str_replace('*', '', $trimmedSPattern)));

                      foreach ($explodePattern as $word) {
                        if ($word) $customfieldCond .= " OR u.s_value LIKE '%" . $word . "%'";
                      }
                    } else {
                       $customfieldCond .= " OR u.s_value LIKE '%" . trim($trimmedSPattern, '"') . "%'";
                    }
« Last Edit: August 06, 2019, 10:55:31 pm by marius-ciclistu »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #102 on: August 06, 2019, 11:05:00 pm »
Sorry i didn't understand. Where should i put this code? Please explain. Thanks

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #104 on: August 07, 2019, 12:24:40 am »