2013-10-07 3 views
0

В нашем CakePHP приложении мы имеем массив так:Как индексировать и искать массив в Solr с PHP

Array 
(
    [0] => Array 
     (
      [Event] => Array 
       (
        [id] => 1 
        [org_id] => 1 
        [name] => Troubadour 
        [url_seo] => think-alone 
        [description] => Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
        [category_id] => 1 
        [sub_category_id] => 1 
        [special_offer] => yes 
        [capacity] => 100 
        [visibility] => E 
        [location] => Old National Centre  502 North New Jersey St Indianapolis, IN, 46204 
        [address] => Old National Centre  502 North New Jersey St Indianapolis, IN, 46204 
        [city] => Indianapolis 
        [state] => WA 
        [country] => US 
        [zipcode] => 98828 
        [fb_url] => https://www.facebook.com/Think Alone 
        [twitter_url] => https://www.twitter.com/Think Alone 
        [status] => A 
        [featured] => Y 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [Organization] => Array 
       (
        [id] => 1 
        [user_id] => 2 
        [name] => test org 
        [company_profile] => We are a company built on integrity 
        [motto] => Engineering Knowledge 
        [logo] => 
        [website] => http://www. test org.com/ 
        [subdomain] => 
        [timezone] => 
        [currency] => 
        [video_link] => 
        [company_email] => [email protected] test org.com 
        [contact_address] => test org Technologies. 4th and 5th floor, Asset Iris Building, N F Gate Main Road, Tripunithura, Cochin, India - 682 301 
        [contact_phone] => + 91 484 2785 833 
        [contact_mobile] => 
        [city] => Cochin 
        [state] => Ernakulam 
        [country] => india 
        [zipcode] => 682 301 
        [email_notification] => 1 
        [fb_url] => https://www.facebook.com/ test org 
        [twitter_url] => https://www.twitter.com/ test org 
        [status] => 1 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [Category] => Array 
       (
        [id] => 1 
        [name] => Business 
        [image] => 
        [category_code] => business 
        [status] => 1 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [SubCategory] => Array 
       (
        [id] => 1 
        [category_id] => 1 
        [name] => Advertising & Marketing 
        [image] => 
        [status] => 1 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [EventDate] => Array 
       (
        [0] => Array 
         (
          [id] => 1 
          [event_id] => 1 
          [start_date] => 2013-09-21 
          [start_time] => 10:00:00 
          [start_session] => A 
          [end_date] => 2013-09-22 
          [end_time] => 5:00:00 
          [end_session] => P 
          [created] => 2013-09-13 00:00:00 
          [modified] => 2013-09-13 00:00:00 
         ) 

        [1] => Array 
         (
          [id] => 9 
          [event_id] => 1 
          [start_date] => 2013-09-23 
          [start_time] => 10:00:00 
          [start_session] => A 
          [end_date] => 2013-09-24 
          [end_time] => 5:00:00 
          [end_session] => P 
          [created] => 2013-09-19 00:00:00 
          [modified] => 2013-09-19 00:00:00 
         ) 

        [2] => Array 
         (
          [id] => 7 
          [event_id] => 1 
          [start_date] => 2013-09-27 
          [start_time] => 10:00:00 
          [start_session] => A 
          [end_date] => 2013-09-28 
          [end_time] => 5:00:00 
          [end_session] => P 
          [created] => 2013-09-18 00:00:00 
          [modified] => 2013-09-18 00:00:00 
         ) 

        [3] => Array 
         (
          [id] => 14 
          [event_id] => 1 
          [start_date] => 2013-09-29 
          [start_time] => 10:00:00 
          [start_session] => A 
          [end_date] => 2013-09-30 
          [end_time] => 5:00:00 
          [end_session] => P 
          [created] => 2013-09-25 00:00:00 
          [modified] => 2013-09-25 00:00:00 
         ) 

        [4] => Array 
         (
          [id] => 6 
          [event_id] => 1 
          [start_date] => 2013-10-15 
          [start_time] => 10:00:00 
          [start_session] => A 
          [end_date] => 2013-10-15 
          [end_time] => 5:00:00 
          [end_session] => P 
          [created] => 2013-09-18 00:00:00 
          [modified] => 2013-09-18 00:00:00 
         ) 

       ) 

      [EventMedia] => Array 
       (
        [0] => Array 
         (
          [id] => 1 
          [event_id] => 1 
          [image_url] => upcom-img1.jpg 
          [video_url] => 
          [created] => 2013-09-25 00:00:00 
          [modified] => 2013-09-25 00:00:00 
         ) 

        [1] => Array 
         (
          [id] => 6 
          [event_id] => 1 
          [image_url] => upcom-img4.jpg 
          [video_url] => 
          [created] => 0000-00-00 00:00:00 
          [modified] => 0000-00-00 00:00:00 
         ) 

       ) 

      [EventTicket] => Array 
       (
        [0] => Array 
         (
          [id] => 1 
          [event_id] => 1 
          [name] => VIP Early Bird Experience 
          [inventory] => 60 
          [pricing] => P 
          [price] => 30 
          [more_info] => It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable Eng 
          [sale_start_date] => 2013-09-15 
          [sale_start_time] => 10.00 AM 
          [sale_end_date] => 2013-09-20 
          [sale_end_time] => 5.00 PM 
          [min_tickets_per_order] => 1 
          [max_tickets_per_order] => 1 
          [ticket_series] => 1_1000 
          [created] => 2013-09-13 00:00:00 
          [modified] => 2013-09-13 00:00:00 
         ) 

        [1] => Array 
         (
          [id] => 2 
          [event_id] => 1 
          [name] => Craft Beer Heaven 
          [inventory] => 40 
          [pricing] => P 
          [price] => 20 
          [more_info] => It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable Eng 
          [sale_start_date] => 2013-09-16 
          [sale_start_time] => 10.00 AM 
          [sale_end_date] => 2013-09-20 
          [sale_end_time] => 5.00 PM 
          [min_tickets_per_order] => 1 
          [max_tickets_per_order] => 1 
          [ticket_series] => 1_1061 
          [created] => 2013-09-13 00:00:00 
          [modified] => 2013-09-13 00:00:00 
         ) 

       ) 

     ) 

    [1] => Array 
     (
      [Event] => Array 
       (
        [id] => 10 
        [org_id] => 1 
        [name] => Music Night 
        [url_seo] => music-night 
        [description] => Contrary to popular belief, Lorem Ipsum is not simply random text. 
        [category_id] => 2 
        [sub_category_id] => 3 
        [special_offer] => no 
        [capacity] => 30 
        [visibility] => E 
        [location] => Los Angeles 
        [address] => The Echo  1822 W Sunset Blvd Los Angeles, California, 90026 
        [city] => Los Angeles 
        [state] => California 
        [country] => US 
        [zipcode] => 90026 
        [fb_url] => http://www.facebook.com/music-night 
        [twitter_url] => http://www.twitter.com/music-night 
        [status] => A 
        [featured] => N 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [Organization] => Array 
       (
        [id] => 1 
        [user_id] => 2 
        [name] => test org 
        [company_profile] => We are a company built on integrity 
        [motto] => Engineering Knowledge 
        [logo] => 
        [website] => http://www. test org.com/ 
        [subdomain] => 
        [timezone] => 
        [currency] => 
        [video_link] => 
        [company_email] => [email protected] test org.com 
        [contact_address] => test org Technologies. 4th and 5th floor, Asset Iris Building, N F Gate Main Road, Tripunithura, Cochin, India - 682 301 
        [contact_phone] => + 91 484 2785 833 
        [contact_mobile] => 
        [city] => Cochin 
        [state] => Ernakulam 
        [country] => india 
        [zipcode] => 682 301 
        [email_notification] => 1 
        [fb_url] => https://www.facebook.com/ test org 
        [twitter_url] => https://www.twitter.com/ test org 
        [status] => 1 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [Category] => Array 
       (
        [id] => 2 
        [name] => Music & nightlife 
        [image] => 
        [category_code] => music 
        [status] => 1 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [SubCategory] => Array 
       (
        [id] => 3 
        [category_id] => 2 
        [name] => music sub1 
        [image] => 
        [status] => 1 
        [created] => 2013-09-13 00:00:00 
        [modified] => 2013-09-13 00:00:00 
       ) 

      [EventDate] => Array 
       (
       ) 

      [EventMedia] => Array 
       (
       ) 

      [EventTicket] => Array 
       (
       ) 

     ) 

) 

Мы хотим, чтобы индексировать этот массив и хотим найти событие с ивент-именем, организация -name, event-city и т. д.

Что мы делаем?

Мы очень новые в Solr и сейчас мы используем SolrPhpClient для этого, но на основе этого массива он становится очень трудно ....

Все помогает приветствуется ....

UPDATE


у нас есть CakePHP apllication, в том, что там есть поиск fetaure. Таким образом, мы хотим интегрировать Apache Solr для поиска ...

Это обучающая мы следовали:

http://www.webdesignermag.co.uk/tutorials/how-to-add-search-with-solr/ 

Bu его для чистого PHP, нам нужно интегрировать его в CakePHP.

Как мы можем это сделать?

Согласно приведенному выше учебник, там нужно сначала проиндексировать все данные и записи перед поиском ....

Так выше массив наши все данные сейчас ..

Когда мы входим в поиск текст, как Troubadour и города как Indianapolis, то условие поиска будет ниже:

(Event.name = Troubadour OR Event.location = Troubadour OR Organization.name = Troubadour) AND Event.city = Indianapolis 

Это наш сценарий ....

Anyboady помогите мне ... Его растрачивает мой 3-й день и все еще .....

+0

пожалуйста внятно объяснить, что вы хотите в этом массиве ? –

+0

@NathanSrivi, проверьте мои обновления ...... – Kichu

ответ

0

Предполагая, что вы не можете фильтровать данные непосредственно в своей базе данных и что вы должны фильтровать полученный массив (но, пожалуйста, объясните нам, почему вы не можете), CakePHP позволяют извлекать отфильтрованные данные из массива, как это:

$filteredArray = Hash::extract($array, '{n}.Event[name=Troubadour]'); 

см CakePHP Hash

надеюсь, что это ответ на ваш вопрос

+0

Пожалуйста, проверьте мои обновления ...... – Kichu

Смежные вопросы