Refactor webapp into elasticsearch plugin