Skip to main content

Doofinder's search & management API client

Project description

Doofiner Python Client (work in progress)

This library is a python wrapper for Doofinder Management API 1 and the Doofinder Search API 4

Installation

pip install pydoof

Usage

Management API:

import pydoof
pydoof.API_KEY = 'eu1-s34v2sdfs4werdfsfwclsss'

for se in pydoof.SearchEngine.all():
    print se.name
    accepted, task_id = se.process() # Parse and index the data feed of the Search Engine
    se.process_info()  # Get info of the current/most-recent 'process' task
    se.task_info(task_id) # get info of any task
    se.logs()  # Get the last logs of the Search Engine

You can also make changes to a specific Search Engine:

# Select the SearchEngine with the hashid identificator
search_engine = pydoof.SearchEngine('abc32sfasdf3vadsfsafass343')

# Get a list of the data types of the SearchEngine
search_engine.get_types()

# Add a type of data to the SearchEngine
search_engine.add_type('product')

# Delete a type of data (and all its items) from the SearchEngine

# Get an item of the 'product' type
item = search_engine.get_item('product', item_id)

# Add an item to the 'product' type
added_item_id = search_engine.add_item('product', item)

# Add multiple items to the 'product' type

[added_id1, added_id2, added_id3] = search_engine.add_items('product', [item1, item2, item3])

# Delete an item from the 'product' type
search_engine.delete_item('product', item_id)

# Update or create an item to the 'product' type
# If item_id does not exist, the item is created
search_engine.update_item('product', item_id, item)

# Update or create multiple items
# all items need to have "id" property (item1['id'])
search_engine.update_items('product', [item1, item2, item3])

# Iterate over all items of the 'product' type
for item in search_engine.items('product'):
    print item.id
    print item.description

# Get the 2nd page of items (from numbers 11 to 20)
search_engine.items('product', 2)

Search API

import pydoof
pydoof.API_KEY = 'eu1-s34v2sdfs4werdfsfwclsss'

search_engine = pydoof.SearchEngine('abc32sfasdf3vadsfsafass343')

query_response = search_engine.query('test query', 1)
query_response.total  # The total number of results
query_response.max_score  # The maximum score obtained
query_response.query_name  # The query_name used by the search algorithm

for item in query_response.get_items():
    print item.id
    print item.body

# Making queries with filters and a specific query_name
search_engine.query('test query', 1,
    {
        'brand': ['nike', 'asics'],
        'price': {'from': 2.45, 'to': 100}
    },
    'match_and'  # the query_name
)

# Any keyword argument is passed as req parameter
search_engine.query('test query', rpp=12, lang='pt', transfomer='dflayer')

# Use of the sort parameter
query_response = search_engine.query(
    query_term='test query',
    sort= [{'namet':'asc'}, {'update_timestamp': 'desc'}])

# You can use lists as keyword arguments, too.
# The will be translated to repeated req parameters
search_engine.query('test query', type=['product', 'article'])

API Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyDoof-2.2.1.tar.gz (8.2 kB view details)

Uploaded Source

File details

Details for the file PyDoof-2.2.1.tar.gz.

File metadata

  • Download URL: PyDoof-2.2.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyDoof-2.2.1.tar.gz
Algorithm Hash digest
SHA256 b6bc4a5cfd126a767d40561ed1b8006a63051bc7d2d0eb7504552f5a53ee83ca
MD5 468c5565047e2c824dcb45a28f9e0360
BLAKE2b-256 ec92fef8804e6c2fee296826431c62057114e07a4ce0f4c505d18ad415e804e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page