This issue is part of meta issue #1931088: [META] Fixing tests

When we add Location field to the node and create search index with Search API we can't see location fields there. The reason of this is because location module is not integrated with Entity API.

Here is patch that allows to add Location fields to index (I tried with Apachesolr index).

So now it would be possible to build facets like "Country name".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

paulgemini’s picture

Hmmm. I've added this in my location/contrib in a new directory, location_entity, and it's not showing up in my list of modules to activate.

ygerasimov’s picture

Very interesting. Can you check please once again? The name of the module is Location Entity under Location group.

paulgemini’s picture

Nevermind. Misnamed a file. Knew I'd done something silly but had a mental block!

Will give it a try tomorrow.

paulgemini’s picture

Activated Location Entity and got this ctools error:

Notice: Undefined property: stdClass::$options in _ctools_export_unpack_object() (line 775 of /home/content/09/7651809/html/myavail/sites/all/modules/ctools/includes/export.inc).
Notice: Undefined property: stdClass::$options in _ctools_export_unpack_object() (line 775 of /home/content/09/7651809/html/myavail/sites/all/modules/ctools/includes/export.inc).

Maybe related? Or possible unrelated. Not sure...

paulgemini’s picture

Ok - probably not related...

paulgemini’s picture

Hey this seems to be working. I'm seeing these in my facet list.

paulgemini’s picture

Status: Needs review » Reviewed & tested by the community
bryancasler’s picture

Active discussion on the issue happening over here #1209576: problems with ctools on update.php and login pages

deeve’s picture

@ygerasimov: I get the following error when I attempt to apply location_entity.patch using cygwin to Location 7.x-3.x-dev (.info file is created correctly then I get the following):

patching file b/contrib/location_entity/location_entity.module
patch unexpectedly ends in middle of line
patch: **** malformed patch at line 83:

anyone else get this?

..also noticed there doesn't appear to be code to create an .install file?

ygerasimov’s picture

FileSize
935 bytes

@daeve, yes module location_entity doesn't have .install file. Very strange patch can't be applied as it plain new files being added. I suspect problems in cygwin.

Here is module itself in archive.

deeve’s picture

@ygerasimov: thanks for the file - I'd actually already created my own in between from your original patch file ;)
Have now managed to enable the module but doesn't seem to have had any effect. I thought this would enable Location fields to be indexed & visible for Search API module to use? I have cleared my cache several times & run cron.

ygerasimov’s picture

@deeve, you need to add location fields to your Search API index in order them to be indexed.

deeve’s picture

@ygerasimov: I've tried but they don't appear as an option to select in Search API index. When I imported my nodes I created a custom Content Type but used the location:city, location:postal code fields etc for the address. Only the other fields I created are now available to select in Search API index.

Any suggestions how I can include location fields?

ygerasimov’s picture

@deeve please check "Add related fields" selectbox and confirm that you don't have your location field there.

deeve’s picture

@ygerasimov: First thing I did & I don't. Just standard fields available:

Author, Translation Source node, Tags, Image, Forums, Description.

daemonsy’s picture

Hi, is this supposed to work on user locations as well? Sigh, couldn't get it to show in the search API index as well.

deeve’s picture

@daemonsy: I'm now wondering whether it may be because when I imported data into my custom Content Type, I'd used the location module: locations.City & location module: locations.Postal Code fields which were available within my Feeds node processor's mapping UI. I'm going to try deleting all nodes & re-importing but this time manually declaring the Location fields within the Content Type first as only these fields appear as options within the Search API setup.

deeve’s picture

That worked :)

Shadlington’s picture

Following this with interest

daemonsy’s picture

@deeve Hi sorry for the late reply. I got my installation to work.

It's weird. I add a location field to a NODE and then add it into a profile2 type as an EXISTING field.

Then it works. Search API sees it. I don't know why.

Haha on a side note, is there any way to get email notifications for threads you are active in?

Thanks man.

deeve’s picture

@daemonsy: I don't believe there currently is a way of being notified by email on here, other than contributing to a thread & then monitor the responses within 'Your Dashboard'. The other way most people seem to manage is to place the word 'subscribe' if they're not contributing. Compared to other similar sites, this practice seems nearly as convoluted as Drupal itself sometimes ..go figure :)

daemonsy’s picture

Haha your comment on Drupal is spot on. Thanks mate.

RaulMuroc’s picture

Should we expect this works on Location CCK locations?

javdich’s picture

I gave this module a quick test tonight. I'm using Search API with the Database search. I'm also using it with the Views Search. The module works perfectly with Location CCK fields. It did not seem to work with Node Locations, although I use Location CCK for my application, so I didn't spend to much time.

Thanks for the work!

javdich’s picture

FileSize
2.76 KB

One thing I did find was when I used facets for searching, it seems to index city that are two words such as "New York" or "Prince Albert" on two lines.
In my example I added a town in Saskatchewan, Canada called "Prince Albert" and the facet comes up twice. "prince" on the first line "albert" on the second. See attached screenshot for clarification.

javdich’s picture

Oops, Fixed it by indexing province and city by "String" instead or "Fulltext" and re-indexed. This solved my problem.

Alconaft43’s picture

What about to apply patch to dev version?

RaulMuroc’s picture

Commit this please :-)!

podarok’s picture

Status: Reviewed & tested by the community » Postponed

postponed before tests fix
#1931088: [META] Fixing tests

podarok’s picture

Status: Postponed » Needs review

#1931088-3: [META] Fixing tests mostly fixed for 7.x-3.x branch
this one needs review

podarok’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

this one needs tests

podarok’s picture

Title: Integration with Entity API, Search API » [Needs Tests]Integration with Entity API, Search API

commited pushed to 7.x-3.x
+ better title

Desi Raaj’s picture

Will this allow Distance / Proximity exposed filter to be used with Search_API view? I'm using Database server.

podarok’s picture

Category: feature » task

looks like this is a task after pushing commit

Desi Raaj’s picture

ok nice, sounds good.

fehin’s picture

Looking for the proximity/distance feature with search API too.

xeeshangulzar’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

location_entity.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, location_entity.patch, failed testing.

xeeshangulzar’s picture

Status: Needs work » Needs review

location_entity.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs tests

The last submitted patch, location_entity.patch, failed testing.

podarok’s picture

#39 - this one already commited - llok at #32
It never pass tests anymore )))

Media Crumb’s picture

So is this patched an in the current dev version?

RaulMuroc’s picture

Same question, confused if this is already committed as said in #32 or needs more testing/improving. :S

RaulMuroc’s picture

Issue summary: View changes

update meta

nasia123’s picture

I would like to user the location module with the search api. This is currently supported for the geofiled in this module , https://drupal.org/project/search_api_location
I also posted a question in the module's page
https://drupal.org/node/1480906

after reading this thread I thought that location module is on the right track on supporting search API, but I am confused since I don't understand if this is now working/commited or not.

esod’s picture

Issue summary: View changes
FileSize
37.14 KB

It's not working. I've enabled location_entity module and tried the location module with both 7.x-3.3 and 7.x-3.3+2-dev. And still the fatal error: EntityMetadataWrapperException: Unknown data property field_location.

my code looks like this:

    $location = array(
      array(
      'latitude' => $geo_location_latitude,
      'longitude'   => $geo_location_longitude,
      'country'   => $geo_country,
      ));

    $ewrapper->field_location->set($location);

All the other fields working in the ewrapper.

esod’s picture

Since I could get latitude and longitude or country to write on node_save(), but not both together, my workaround was to update country in the location table with this query

      $sql = "
        UPDATE location loc JOIN location_instance li ON (loc.lid = li.lid)
        SET loc.country = :type1
        WHERE li.nid = :type2;
      ";
      
      if(isset($geo_country)) {
        $args = array(':type1' => $geo_country, ':type2' => $nid);
        db_query($sql, $args); 
      }

Run this query after node_save(). I couldn't maintain the $ewrapper for this import because of location entity not working.

netgeek123 queued location_entity.patch for re-testing.

The last submitted patch, location_entity.patch, failed testing.

ravikiran@gocoop’s picture

Hi Guys,

I have been reading this thread and it shows, the issue still exists.

I have used Default Node Index for Indexing Node data. I couldn't find Location module fields for some reason. I have enabled Location Entity and tried but Didn't help.

When I use Location CCK module and add a field of Location type, Search api starts reading the fields. I would have loved to use this than using Node locations. But all my data is saved Under Node Location fields and I am not able to integrate them with Search API.

What could be the best suggestions or Solutions i can get?

Please help! Im Badly in need. Thanks in Advance.

bebop-design’s picture

Remove "new file" lines in patch file

bebop-design’s picture

edxxu’s picture

I am using Location 7.x-3.7 with Location entity and Location CCK enabled. I add a location field to a content type, but location data can't be indexed. And patch in #50 doesn't work for me.

edxxu’s picture

Here is the patch, please review. Please clear cache, clear all indexed data and re-index to test this patch.

edxxu’s picture

Status: Needs work » Needs review

The last submitted patch, 50: location_entity.patch, failed testing.

lhuria94’s picture

Hi @edxxu,

Last patch still does not work. Tried that patch, cleared cache & Re indexed data. Still Location field not available in field list.

Thanks

lhuria94’s picture

Status: Needs review » Needs work
SpadXIII’s picture

Is the patch in #50 and #53 needed at all? I just enabled this module, did not apply any patch, and I could add the Location-fields to my search-index just fine?

AlfTheCat’s picture

#53 works for me, thanks!

gambry’s picture

I confirm what @SpadXIII says on #58: I use version 3.7 and enabling location_entity works on Search API without any patch.

You probably want to look at supporting search_api_location implementing the field property suggested in here

I can provide a patch if that would speed up the process.

mausolos’s picture

Whoops! I posted this on this issue, but I think this is actually where I should have posted it, so x-post!

I cannot get this to work, with or without the patch (#53). No matter what I do, the lat/lng field does not come up, either in the field list or the add field drop-down. I do get the Address field, but since my goal is to search via view that has/returns province, state, country and title (with each of these as an independent output field), Address is almost useless.

  • Location Search and Node Search are checked off under admin/config/search/settings (Active search modules).
  • I'm using search_api/search_api_solr talking to a SOLR 5.4.1 instance.
  • In my Search Index, I have only one Bundle/content type checked (the one for which we have all the locations entered).
  • Data alterations are: Exclude unpublished nodes, Complete entity view (view mode: Full content).
  • Enabled processors are:
    • Ignore case (Fields to run on: Title, Address, Entity HTML output)
  • HTML Filter (Fields to run on: Address, Entity HTML output)
  • Tokenizer (Fields to run on: Title, Address, Entity HTML output)
  • Highlighting (default settings, no exclusions)
 Core                                   Search (search)                                                 Module  Enabled        7.50
 Display Suite                          Display Suite Search (ds_search)                                Module  Enabled        7.x-2.14
 Fields                                 Location CCK (location_cck)                                     Module  Enabled        7.x-3.7
 Location                               GMap (gmap)                                                     Module  Enabled        7.x-2.11
 Location                               GMap Location (gmap_location)                                   Module  Enabled        7.x-2.11
 Location                               Location (location)                                             Module  Enabled        7.x-3.7
 Location                               Location Entity (location_entity)                               Module  Enabled        7.x-3.7
 Location                               Location Search (location_search)                               Module  Enabled        7.x-3.7
 Location                               Node Locations (location_node)                                  Module  Enabled        7.x-3.7
 Other                                  Search 404 (search404)                                          Module  Enabled        7.x-1.4
 Search                                 Database search (search_api_db)                                 Module  Enabled        7.x-1.5
 Search                                 Search API (search_api)                                         Module  Enabled        7.x-1.20
 Search                                 Search API location (search_api_location)                       Module  Enabled        7.x-2.0-beta2
 Search                                 Search API location views (search_api_location_views)           Module  Enabled        7.x-2.0-beta2
 Search                                 Search views (search_api_views)                                 Module  Enabled        7.x-1.20
 Search                                 Solr search (search_api_solr)                                   Module  Enabled        7.x-1.11

Location Entity was enabled from the get-go. Not sure what to do next. Any ideas? Did I miss something?

Thanks!
Charles