Advertisement:

Author Topic: Custom field search  (Read 5441 times)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #15 on: January 25, 2018, 09:08:14 am »
Nice job :)
If nobody comes with a bether solution for searching in metas too, then a cron job could be made to update all items' descriptions in groups by their ids each hour (to avoid updating them all at once).

Thank you but i think we should find another way. Because with this way we have to edit all of descriptions and this is not good. Editing users items description is not good without a reason.
Solving this is easy for some Users here in this forum. But they don't want to help. Or they do if we pay.
Please you find another way and im working on other way now, i will let you know soon. And you update here if you find a way before me. Thanks
« Last Edit: January 25, 2018, 09:10:48 am by Sophia_OS »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #16 on: January 25, 2018, 09:43:41 am »
Another way would be to index the metas in db just like title and description are indexed and adjust the query to search also in those flelds...but:
1.You would have to regenerate the indexes in db anyway for all the items.(this also if you change the description via sql without editing the item)
2.The metas are stored in meta_fields table and the item's metas in item_meta table, so you should index the columns s_value, fk_i_field_id and fk_i_item_id from the last and s_name from the first table depending by fk_i_field_id column from the above first table.

The easiest way would be to query directly into these tables without using mysql fulltext search . That would impact your query times and server load.
« Last Edit: January 25, 2018, 09:46:08 am by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #17 on: February 01, 2018, 11:39:02 pm »
Have you received other solutions for this? ( I saw that olx has this finctionality)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #18 on: February 09, 2018, 07:21:12 pm »
Have you received other solutions for this? ( I saw that olx has this finctionality)

@marius-ciclistu
Not yet, but I'm working on this. I will let you know when i completely solve it.
Who is olx? He knows the solution? Please ask him to share with us.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #19 on: February 09, 2018, 08:47:37 pm »
Olx is a big classifields site that acts in some european countries. :)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #20 on: February 11, 2018, 11:52:00 pm »
Olx is a big classifields site that acts in some european countries. :)

 :D
With olx we can make a free classified website like osclass? And it has that ability to search both in items and custom-fiels in one text-box?
Please give me more information about this. Thanks.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #21 on: February 12, 2018, 12:03:53 am »
:)) no man:)) It's a big company that has limits on free ads. That is why I discovered osclass.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #22 on: February 12, 2018, 01:04:33 am »
:)) no man:)) It's a big company that has limits on free ads. That is why I discovered osclass.

 ;D

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #23 on: June 15, 2018, 12:03:37 am »
Have you received other solutions for this? ( I saw that olx has this finctionality)

@marius-ciclistu
hey, did you find a solution for this?

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #24 on: June 15, 2018, 08:04:03 am »
I didn't.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #25 on: June 15, 2018, 10:41:35 pm »
« Last Edit: June 15, 2018, 10:51:47 pm by Sophia_OS »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #26 on: June 15, 2018, 11:45:51 pm »
Another way would be to index the metas in db just like title and description are indexed and adjust the query to search also in those flelds...but:
1.You would have to regenerate the indexes in db anyway for all the items.(this also if you change the description via sql without editing the item)
2.The metas are stored in meta_fields table and the item's metas in item_meta table, so you should index the columns s_value, fk_i_field_id and fk_i_item_id from the last and s_name from the first table depending by fk_i_field_id column from the above first table.

The easiest way would be to query directly into these tables without using mysql fulltext search . That would impact your query times and server load.

lets work on this way

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom field search
« Reply #27 on: June 17, 2018, 11:31:06 am »
I don't know if changing the way the search is made is not going to have a negative inpact on your server.... osclass wasn't built to support custom fields search... in the maner it does the search.

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #28 on: June 17, 2018, 08:37:25 pm »
.
« Last Edit: June 17, 2018, 08:43:57 pm by Sophia_OS »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: Custom field search
« Reply #29 on: June 17, 2018, 08:44:08 pm »
@marius-ciclistu
Marius, finally i solved it by creating a function in function.php :) now its working very good. The only problem i have now, it doesn't search by location. Location in search doesn't work. Why? Can you please help me to solve this?

Put this code in your function.php

Code: [Select]
function cust_search_keyword_wildcard_with_customfield($params) {

    if ($params['sPattern']) {
        $mSearch =  Search::newInstance();
        $query_elements = (array) json_decode($mSearch->toJson());
        $pattern = $query_elements['sPattern'];


        $query_elements['sPattern'] = str_replace(' ', '* ', $pattern) . '*';

        $mSearch->setJsonAlert($query_elements);

        // Search by customfield too
        $mSearch->addJoinTable(count($query_elements['tables_join']), DB_TABLE_PREFIX."t_item_meta u", "pk_i_id = u.fk_i_item_id", 'LEFT');

        $aPattern = explode(' ', $pattern);
        $customfieldCond = '';

        foreach ($aPattern as $word) {
            if ($word) $customfieldCond .= sprintf(" || u.s_value like '%%%s%%'", $word);
        }

        $mSearch->addConditions("1 = 1 " . $customfieldCond);
        $mSearch->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
    }
}

osc_add_hook('search_conditions', 'cust_search_keyword_wildcard_with_customfield', 1);