@@ -70,6 +70,11 @@ setup:
70
70
type : scaled_float
71
71
scaling_factor : 100
72
72
doc_values : false
73
+ text :
74
+ type : text
75
+ fielddata : true
76
+ text_no_field_data :
77
+ type : text
73
78
token_count :
74
79
type : token_count
75
80
analyzer : standard
@@ -110,6 +115,8 @@ setup:
110
115
half_float_no_doc_values : 3.140625
111
116
scaled_float : 3.14
112
117
scaled_float_no_doc_values : 3.14
118
+ text : " Lots of text."
119
+ text_no_field_data : " Lots of text."
113
120
token_count : count all these words please
114
121
115
122
- do :
@@ -150,6 +157,8 @@ setup:
150
157
half_float_no_doc_values : [2.234, 1.123]
151
158
scaled_float : [-3.5, 2.5]
152
159
scaled_float_no_doc_values : [2.5, -3.5]
160
+ text : ["Lots of text.", "even more text", "SOOOOO much text"]
161
+ text_no_field_data : ["Lots of text.", "even more text", "SOOOOO much text"]
153
162
154
163
155
164
- do :
@@ -2719,6 +2728,264 @@ setup:
2719
2728
source : " int value = field('dne').get(1, 1); value"
2720
2729
- match : { hits.hits.0.fields.field.0: 1 }
2721
2730
2731
+ ---
2732
+ " text " :
2733
+ - do :
2734
+ search :
2735
+ rest_total_hits_as_int : true
2736
+ body :
2737
+ query : { term: { _id: "1" } }
2738
+ script_fields :
2739
+ field :
2740
+ script :
2741
+ source : " doc['text'].get(0)"
2742
+ - match : { hits.hits.0.fields.field.0: lots }
2743
+
2744
+ - do :
2745
+ search :
2746
+ rest_total_hits_as_int : true
2747
+ body :
2748
+ query : { term: { _id: "1" } }
2749
+ script_fields :
2750
+ field :
2751
+ script :
2752
+ source : " doc['text'].value"
2753
+ - match : { hits.hits.0.fields.field.0: lots }
2754
+
2755
+ - do :
2756
+ search :
2757
+ rest_total_hits_as_int : true
2758
+ body :
2759
+ sort : [ { rank: asc } ]
2760
+ script_fields :
2761
+ field :
2762
+ script :
2763
+ source : " field('text').get('')"
2764
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2765
+ - match : { hits.hits.1.fields.field.0: "" }
2766
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2767
+
2768
+ - do :
2769
+ search :
2770
+ rest_total_hits_as_int : true
2771
+ body :
2772
+ sort : [ { rank: asc } ]
2773
+ script_fields :
2774
+ field :
2775
+ script :
2776
+ source : " /* avoid yaml stash */ $('text', '')"
2777
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2778
+ - match : { hits.hits.1.fields.field.0: "" }
2779
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2780
+
2781
+ - do :
2782
+ search :
2783
+ rest_total_hits_as_int : true
2784
+ body :
2785
+ sort : [ { rank: asc } ]
2786
+ script_fields :
2787
+ field :
2788
+ script :
2789
+ source : " String defaultText = 'default text'; field('text').get(defaultText)"
2790
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2791
+ - match : { hits.hits.1.fields.field.0: "default text" }
2792
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2793
+
2794
+ - do :
2795
+ search :
2796
+ rest_total_hits_as_int : true
2797
+ body :
2798
+ sort : [ { rank: asc } ]
2799
+ script_fields :
2800
+ field :
2801
+ script :
2802
+ source : " String defaultText = 'default text'; $('text', defaultText)"
2803
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2804
+ - match : { hits.hits.1.fields.field.0: "default text" }
2805
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2806
+
2807
+ - do :
2808
+ search :
2809
+ rest_total_hits_as_int : true
2810
+ body :
2811
+ sort : [ { rank: asc } ]
2812
+ script_fields :
2813
+ field :
2814
+ script :
2815
+ source : " field('text').get(1, '')"
2816
+ - match : { hits.hits.0.fields.field.0: "" }
2817
+ - match : { hits.hits.1.fields.field.0: "" }
2818
+ - match : { hits.hits.2.fields.field.0: "SOOOOO much text" }
2819
+
2820
+ - do :
2821
+ search :
2822
+ rest_total_hits_as_int : true
2823
+ body :
2824
+ sort : [ { rank: asc } ]
2825
+ script_fields :
2826
+ field :
2827
+ script :
2828
+ source : " String defaultText = 'default text'; field('text').get(1, defaultText)"
2829
+ - match : { hits.hits.0.fields.field.0: "default text" }
2830
+ - match : { hits.hits.1.fields.field.0: "default text" }
2831
+ - match : { hits.hits.2.fields.field.0: "SOOOOO much text" }
2832
+
2833
+ - do :
2834
+ search :
2835
+ rest_total_hits_as_int : true
2836
+ body :
2837
+ sort : [ { rank: asc } ]
2838
+ script_fields :
2839
+ field :
2840
+ script :
2841
+ source : " field('text').get(1, '')"
2842
+ - match : { hits.hits.0.fields.field.0: "" }
2843
+ - match : { hits.hits.1.fields.field.0: "" }
2844
+ - match : { hits.hits.2.fields.field.0: "SOOOOO much text" }
2845
+
2846
+ - do :
2847
+ search :
2848
+ rest_total_hits_as_int : true
2849
+ body :
2850
+ sort : [ { rank: asc } ]
2851
+ script_fields :
2852
+ field :
2853
+ script :
2854
+ source : " String cat = ''; for (String s : field('text')) { cat += s; } cat + field('text').size();"
2855
+ - match : { hits.hits.0.fields.field.0: "Lots of text.1" }
2856
+ - match : { hits.hits.1.fields.field.0: "0" }
2857
+ - match : { hits.hits.2.fields.field.0: "Lots of text.SOOOOO much texteven more text3" }
2858
+
2859
+ ---
2860
+ " text_no_field_data " :
2861
+ - do :
2862
+ catch : bad_request
2863
+ search :
2864
+ rest_total_hits_as_int : true
2865
+ body :
2866
+ query : { term: { _id: "1" } }
2867
+ script_fields :
2868
+ field :
2869
+ script :
2870
+ source : " doc['text_no_field_data'].get(0)"
2871
+ - match : { error.failed_shards.0.reason.caused_by.type: "illegal_argument_exception" }
2872
+
2873
+ - do :
2874
+ catch : bad_request
2875
+ search :
2876
+ rest_total_hits_as_int : true
2877
+ body :
2878
+ query : { term: { _id: "1" } }
2879
+ script_fields :
2880
+ field :
2881
+ script :
2882
+ source : " doc['text_no_field_data'].value"
2883
+ - match : { error.failed_shards.0.reason.caused_by.type: "illegal_argument_exception" }
2884
+
2885
+ - do :
2886
+ search :
2887
+ rest_total_hits_as_int : true
2888
+ body :
2889
+ sort : [ { rank: asc } ]
2890
+ script_fields :
2891
+ field :
2892
+ script :
2893
+ source : " field('text_no_field_data').get('')"
2894
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2895
+ - match : { hits.hits.1.fields.field.0: "" }
2896
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2897
+
2898
+ - do :
2899
+ search :
2900
+ rest_total_hits_as_int : true
2901
+ body :
2902
+ sort : [ { rank: asc } ]
2903
+ script_fields :
2904
+ field :
2905
+ script :
2906
+ source : " /* avoid yaml stash */ $('text_no_field_data', '')"
2907
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2908
+ - match : { hits.hits.1.fields.field.0: "" }
2909
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2910
+
2911
+ - do :
2912
+ search :
2913
+ rest_total_hits_as_int : true
2914
+ body :
2915
+ sort : [ { rank: asc } ]
2916
+ script_fields :
2917
+ field :
2918
+ script :
2919
+ source : " String defaultText = 'default text'; field('text_no_field_data').get(defaultText)"
2920
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2921
+ - match : { hits.hits.1.fields.field.0: "default text" }
2922
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2923
+
2924
+ - do :
2925
+ search :
2926
+ rest_total_hits_as_int : true
2927
+ body :
2928
+ sort : [ { rank: asc } ]
2929
+ script_fields :
2930
+ field :
2931
+ script :
2932
+ source : " String defaultText = 'default text'; $('text_no_field_data', defaultText)"
2933
+ - match : { hits.hits.0.fields.field.0: "Lots of text." }
2934
+ - match : { hits.hits.1.fields.field.0: "default text" }
2935
+ - match : { hits.hits.2.fields.field.0: "Lots of text." }
2936
+
2937
+ - do :
2938
+ search :
2939
+ rest_total_hits_as_int : true
2940
+ body :
2941
+ sort : [ { rank: asc } ]
2942
+ script_fields :
2943
+ field :
2944
+ script :
2945
+ source : " field('text_no_field_data').get(1, '')"
2946
+ - match : { hits.hits.0.fields.field.0: "" }
2947
+ - match : { hits.hits.1.fields.field.0: "" }
2948
+ - match : { hits.hits.2.fields.field.0: "SOOOOO much text" }
2949
+
2950
+ - do :
2951
+ search :
2952
+ rest_total_hits_as_int : true
2953
+ body :
2954
+ sort : [ { rank: asc } ]
2955
+ script_fields :
2956
+ field :
2957
+ script :
2958
+ source : " String defaultText = 'default text'; field('text_no_field_data').get(1, defaultText)"
2959
+ - match : { hits.hits.0.fields.field.0: "default text" }
2960
+ - match : { hits.hits.1.fields.field.0: "default text" }
2961
+ - match : { hits.hits.2.fields.field.0: "SOOOOO much text" }
2962
+
2963
+ - do :
2964
+ search :
2965
+ rest_total_hits_as_int : true
2966
+ body :
2967
+ sort : [ { rank: asc } ]
2968
+ script_fields :
2969
+ field :
2970
+ script :
2971
+ source : " field('text_no_field_data').get(1, '')"
2972
+ - match : { hits.hits.0.fields.field.0: "" }
2973
+ - match : { hits.hits.1.fields.field.0: "" }
2974
+ - match : { hits.hits.2.fields.field.0: "SOOOOO much text" }
2975
+
2976
+ - do :
2977
+ search :
2978
+ rest_total_hits_as_int : true
2979
+ body :
2980
+ sort : [ { rank: asc } ]
2981
+ script_fields :
2982
+ field :
2983
+ script :
2984
+ source : " String cat = ''; for (String s : field('text_no_field_data')) { cat += s; } cat + field('text_no_field_data').size();"
2985
+ - match : { hits.hits.0.fields.field.0: "Lots of text.1" }
2986
+ - match : { hits.hits.1.fields.field.0: "0" }
2987
+ - match : { hits.hits.2.fields.field.0: "Lots of text.SOOOOO much texteven more text3" }
2988
+
2722
2989
---
2723
2990
" version and sequence number " :
2724
2991
- do :
0 commit comments