Skip to content

Commit

Permalink
Update geonames_solr.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ewlarson committed Nov 19, 2024
1 parent b09d88f commit 1af7a7d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/geonames_solr.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ response = solr.post 'tag', params: {
# Parse the JSON response to extract geoname IDs
geoname_ids = response['response']['docs'].map { |doc| doc['geonameid_i'] }

# Fetch Geoname objects from the database using the extracted IDs
geonames = Geoname.where(id: geoname_ids)
# Fetch Geoname objects from the database using the extracted IDs, preserving order
geonames = Geoname.where(geonameid: geoname_ids).order(Arel.sql("array_position(array[#{geoname_ids.join(',')}], geonameid)"))

# Step 2: Use the geoname IDs to perform a geospatial query with sorting
response = solr.get 'select', params: {
Expand Down Expand Up @@ -165,8 +165,8 @@ class GeonamesTagger
# Parse the response to extract geoname IDs
geoname_ids = response['response']['docs'].map { |doc| doc['geonameid_i'] }

# Fetch Geoname objects from the database using the extracted IDs
geonames = Geoname.where(geonameid: geoname_ids)
# Fetch Geoname objects from the database using the extracted IDs, preserving order
geonames = Geoname.where(geonameid: geoname_ids).order(Arel.sql("array_position(array[#{geoname_ids.join(',')}], geonameid)"))
end

# Method to perform a geospatial search using geoname IDs
Expand All @@ -185,8 +185,8 @@ class GeonamesTagger
# Parse the response to extract geoname IDs
geoname_ids = response['response']['docs'].map { |doc| doc['geonameid_i'] }

# Fetch Geoname objects from the database using the extracted IDs
geonames = Geoname.where(geonameid: geoname_ids)
# Fetch Geoname objects from the database using the extracted IDs, preserving order
geonames = Geoname.where(geonameid: geoname_ids).order(Arel.sql("array_position(array[#{geoname_ids.join(',')}], geonameid)"))
end
end

Expand Down

0 comments on commit 1af7a7d

Please sign in to comment.