issue #267 is also fixed for fuzzy join
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ExtractFunctionsFromJoinConditionRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ExtractFunctionsFromJoinConditionRule.java
index ef78a93..a69839e 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ExtractFunctionsFromJoinConditionRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/ExtractFunctionsFromJoinConditionRule.java
@@ -82,14 +82,16 @@
         FunctionIdentifier fi = fexp.getFunctionIdentifier();
 
         boolean modified = false;
-        if (fi.equals(AlgebricksBuiltinFunctions.AND) || fi.equals(AlgebricksBuiltinFunctions.OR)) {
+        if (fi.equals(AlgebricksBuiltinFunctions.AND) || fi.equals(AlgebricksBuiltinFunctions.OR)
+                || fi.equals(AsterixBuiltinFunctions.GET_ITEM)) {
             for (Mutable<ILogicalExpression> a : fexp.getArguments()) {
                 if (assignFunctionExpressions(joinOp, a.getValue(), context)) {
                     modified = true;
                 }
             }
             return modified;
-        } else if (AlgebricksBuiltinFunctions.isComparisonFunction(fi)) {
+        } else if (AlgebricksBuiltinFunctions.isComparisonFunction(fi)
+                || AsterixBuiltinFunctions.isSimilarityFunction(fi)) {
             for (Mutable<ILogicalExpression> exprRef : fexp.getArguments()) {
                 if (exprRef.getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
                     LogicalVariable newVar = context.newVar();
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
index e95de97..d4c00e4 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
@@ -282,13 +282,14 @@
                         continue;
                     }
                     // At this point we have matched the optimizable func expr at optFuncExprIndex to an assigned variable.
+                    // Remember matching subtree.
+                    optFuncExpr.setOptimizableSubTree(funcVarIndex, subTree);
                     String fieldName = getFieldNameOfFieldAccess(assignOp, subTree.recordType, varIndex);
                     if (fieldName == null) {
                         continue;
                     }
-                    // Set the fieldName in the corresponding matched function expression, and remember matching subtree.
+                    // Set the fieldName in the corresponding matched function expression.
                     optFuncExpr.setFieldName(funcVarIndex, fieldName);
-                    optFuncExpr.setOptimizableSubTree(funcVarIndex, subTree);
                     fillIndexExprs(fieldName, optFuncExprIndex, subTree.dataset, analysisCtx);
                 }
             }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
index e6f8ba8..d7e57d4 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -132,6 +132,7 @@
 
     private final static Set<IFunctionInfo> builtinAggregateFunctions = new HashSet<IFunctionInfo>();
     private static final Set<IFunctionInfo> datasetFunctions = new HashSet<IFunctionInfo>();
+    private static final Set<IFunctionInfo> similarityFunctions = new HashSet<IFunctionInfo>();
     private static final Map<IFunctionInfo, IFunctionInfo> aggregateToLocalAggregate = new HashMap<IFunctionInfo, IFunctionInfo>();
     private static final Map<IFunctionInfo, IFunctionInfo> aggregateToGlobalAggregate = new HashMap<IFunctionInfo, IFunctionInfo>();
     private static final Map<IFunctionInfo, IFunctionInfo> aggregateToSerializableAggregate = new HashMap<IFunctionInfo, IFunctionInfo>();
@@ -1126,5 +1127,16 @@
     public static boolean isSpatialFilterFunction(FunctionIdentifier fi) {
         return spatialFilterFunctions.get(getAsterixFunctionInfo(fi)) != null;
     }
+    
+    static {
+        similarityFunctions.add(getAsterixFunctionInfo(SIMILARITY_JACCARD));
+        similarityFunctions.add(getAsterixFunctionInfo(SIMILARITY_JACCARD_CHECK));
+        similarityFunctions.add(getAsterixFunctionInfo(EDIT_DISTANCE));
+        similarityFunctions.add(getAsterixFunctionInfo(EDIT_DISTANCE_CHECK));
+    }
+
+    public static boolean isSimilarityFunction(FunctionIdentifier fi) {
+        return similarityFunctions.contains(getAsterixFunctionInfo(fi));
+    }
 
 }