⚡ Wp-aggregator-api-document
⚡ Wp-aggregator-api-document
WP Aggregator API
WP Aggregator API is Wrapper Over ElasticSearch Datasource that does queries on Wordpress Content
Data.
Using WP AGG API, we can get the wordpress content data.
Wordpress Data is Stored in ElasticSearch Cluster, And WP AGG API does queries on ES Cluster to fetch
the WP Content data.
Current Version
code version : design-v3
deployment version : D-V2
What is Auto-replication ?
For Wordpress site, we have relation like parent - child between sites.
When Some site is child of parent site then all the changes on post/articles will be replicated to the child
sites after a day.
Auto-replication is process of replicating the post/article content from parent site to child site.
What is SearchAPI ?
SearchAPI is API like WP AGG API. It does search on elasticsearch for wordpress index data.
Types of SearchAPI Endpoint
webresult : Used in Ad API
smart.content : Used in Product Site to show article
qna : Used in QnA Widget
text
# smart.content
http://search-api.proxy.sem.infra/smartContentResults?keyword=eczema+treatment&strategy=es7
http://es.petradigital.agency/fetch?
keyword=site%3Asmart.content+eczema+treatment&limit=1&fc=1&strategy=es7
# qna
http://search-api.proxy.sem.infra/qnaResults?
keyword=eucrisa+atopic+dermatitis&limit=6&offset=0&source=default&strategy=es7
http://es.petradigital.agency/fetch?
keyword=site%3Aqanda.widget+eucrisa+atopic+dermatitis&limit=6&offset=0&strategy=es7
# webresults
http://es.petradigital.agency/fetch/?
&keyword=site:knowledgedesk.net%20car%20insurance%20quotes&limit=10&ver=10&strategy=es7
wp agg api is meant to solve different problem. But the similarity between both is hard to ignore. so we
decided to replace the SearchAPI by including the functionality of it in WP AGG API.
Tech Stack
php 8.0
laravel 9
elasticsearch 7.2
Class Diagram
setup response structure change. default is new . use old if want searchapi no
like response
Additional Filters :
text
- Addtional Filters feature is excluded for strategies like category_tree , links
categories, tags.
- Currently it supports 3 filter i.e. post_modified , post_date, siteurl.
# post_modified & post_date support 4 parmas (gt , gte, lt, lte) value must be in YYYY-
MM-DD format.
*note combination of gt and gte or lt or lte won't work
# siteurl must be of type string.
What is Strategy?
text
- Strategy in WP AGG API is number of ways, we can search and fetch wp content data.
- Each Strategy have it own query fields, unique to it. You can see it in postman
collection api.
text
- tells the articles strategy. how to search the keyword on es fields.
- important fields to be searched in es fields are post_title/title, post_content/content,
post_tags/tags, category
- with this 4 fields, we can search on ES effectively for wp content data.
- so, we made searchModel for this 4 fields.
- With combination from 4 fields - t0c0t0c0
- t0c0t0c0 -> are title,content,tags, category respectively while succeeding number
represents boost for each field.
t1c0t3c2 keyword is search on title, tags with boost 3 and categories with 2 no
Secondary APIs
there are few other APIs. For other than search and aggregation.
text
health check - /ping
# if you cache using wp agg api cache, you should not use it for production usage. use
varnish or other http cache.
flush_cache - /flush_cache
# we cache for aggregation query_type, as aggregation query are heavy on ES. Generally,
Aggregation don't change much. But if lot's of data is changed then you should clear this
flush
flush_cache for aggregation - /flush_cache
# we use redis cache and ttl is 7 days.
# for more detials, see in postman collections api.
Deployment Diagram
#
deployment diagram image
Index Patterns
text
- base prefix : wp-es7-plugin
- for consistenty, remove any special characters in domain_name with -
- ex. vervily.com -> vervily-com , content.vervily.com -> content-vervily-com, vervily-com
- special case : for wordpress domain alias
- if domain is content.vervily.com or blog.vervily.com
- then alias will be [wp-es7-plugin-vervily-com, wp-es7-plugin-content-vervily-com]
Future Plan
Add Support for Multiple ComputeModel for LinksAPI
Add Support for Multi-Indexed Alias
Ref Links
wp agg api prod url
wp agg api stage url
wp agg api repo
project status csv
class diagram and deployment diagram
varnish APS wp agg api url
APS wp agg api url
Grafana Links
redis server
consul
server monitor
request-response
loki