         (map (fn [path]
                [path (map-subset-by-path lexicon path)])
              index-lexicon-on-paths)))
+
+(defn lookup-spec [spec indices]
+  (log/debug (str "index-fn called with spec: " 
+                  (strip-refs
+                   (dissoc (strip-refs spec)
+                           :dag_unify.core/serialized))))
+  (let [result
+        (reduce intersection-with-identity
+                (filter #(not (empty? %))
+                        (map (fn [path]
+                               (let [result
+                                     (get (get indices path)
+                                          (get-in spec path ::undefined))]
+                                 (log/trace (str "subset for path:" path " => " (get-in spec path ::undefined)
+                                                 " = " (count result)))
+                                 result))
+                             index-lexicon-on-paths)))]
+    (log/debug (str "indexed size returned: " (count result)))
+    result))
 
 (defn fo-ps [expr]
   (parse/fo-ps expr fo))

                                v)]
                  (if (not (empty? filtered-v))
                    [k filtered-v]))))
        lexicon-for-generation (lexicon-for-generation lexicon)]
    {:name "small"
     :morph-walk-tree (fn [tree]
                        (do
                          (merge tree

    (log/debug (str "micro lexicon size:" (count (keys micro-lexicon))))
    (clojure.core/merge small
                        {:lexicon micro-lexicon})))

(defn medium []
  (deliver-lexicon)
